I am facing issue while using the django-pgcrypto-fields. Model has charsymmetricfield and emailsymmetricfield.
using pgcrypto externsion in postgres sql, following is the output for below queries
Query 1:
explain analyze (select * from table_name);
above query taking time around 900 ms
but when i am using query with 'pgp_sym_decrypt' it taking longer time around 54 sec, that is too high
Encrypted column is indexed
explain analyze (select
pgp_sym_decrypt("table_name"."sender_contact_person_name",
'encryption_key')::text,
pgp_sym_decrypt("table_name"."sender_contact_person_email", 'encryption_key')::text,
pgp_sym_decrypt("table_name"."sender_contact_person_contact_no",
'encryption_key')::text,
pgp_sym_decrypt("table_name"."recipient_contact_person_name",
'encryption_key')::text,
pgp_sym_decrypt("table_name"."recipient_contact_person_email",
'encryption_key')::text,
pgp_sym_decrypt("table_name"."recipient_contact_person_contact_no",
'encryption_key')::text,
from
"table_name"
where
"table_name"."is_active"
order by
"table_name"."pickup_date_time"
limit 10)
To add Pgcrypto in system i follow below steps
- added pgcrypto extension in postgres sql
- added pgcrypto in INSTALLED_APP in base settings.
- added django-pgcrypto-fields plug in.
- replace model char fields to charpgpsymmetric fields.
- copy data in encrypted format in encrypted fields.
Any input will be very helpful, as system is very slow.
expecting query execution time to be minimum