I have a table with 10 million entries, and one of the column is email address. I want to create a hash index on this column since the queries are all on equality comparisons.
Database: Postgres 8.3.3
Machine: 24GB Ram and 16 cores.
Hash index creation takes about 51 minutes, however, if I create a hash index on lower case of the email address, it takes less than 3 minutes!
Example:
create index xyz on table_xyz using hash(email)
: Takes 51 minutes to create this indexcreate index xyz on table_xyz using hash(lower(email))
: Takes 3 minutes to create this index.
My maintenance_work_mem is set to 16MB. shared_buffers = 1GB
What explains this behavior?