cossacklabs / acra

Database security suite. Database proxy with field-level encryption, search through encrypted data, SQL injections prevention, intrusion detection, honeypots. Supports client-side and proxy-side ("transparent") encryption. SQL, NoSQL.
https://www.cossacklabs.com/acra/
Apache License 2.0
1.32k stars 128 forks source link

[ISSUE] Index on encrypted column #697

Open devendermishra opened 5 months ago

devendermishra commented 5 months ago

Describe the bug In one of my table, there is an encrypted field e_phone. Table has 3 Million of rows. Without using an index, it is taking approx 5sec to search on e_phone field.

After creating a functional index as follows:

CREATE INDEX e_phone_index ON customer_detail((convert(substr(e_phone, 1, 33), binary)));

It is taking less time.

I want to know that what are the other suggested indexes to be create on encrypted columns for searching?

To Reproduce NA

Expected behavior NA

Acra configuration files NA

Environment (please complete the following information):

Additional context NA

Lagovas commented 5 months ago

I'm not sure, but you can try hash index type (only if it supports expressions as a column). Searchable encryption supports only ==/<> operations, so hash index is relevant and can be better. Would appreciate feedback if you would try it.

All other solutions are out-of-scope index capabilities. The next suggestion is partitioning which will reduce the size of the index and reduce amount of rows.