I created a postgres table which looks like:
name ID SNO
jack 12 1
bob 123 2
andy 34 3
jack 23 4
etc. It has a total of 41 million entries. SNO is my primary key of continuous INT values. When I run a query to select a particular SNO, it works lightning fast. However! My need is to run the query on 'name' which should return all instances of a particular name. Note that names need not be unique and are most likely repeated but with different ID's. A query to search for a name takes way to long to find. I tried creating an index on 'name' using this:
CREATE INDEX name ON userlist(name)
However, while this improves performance, it is still way too slow. Is there any way that I can index 'name' which is a 'text' data type to improve access performance as much as accessing the 'int' SNO?
Try to make enough space for the index in memory. The shared_buffers
setting can be helpful in this.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.