简体   繁体   English

PostgreSQL提高访问效率

[英]Postgresql improving access efficiency

I created a postgres table which looks like: 我创建了一个postgres表,如下所示:

name   ID   SNO
jack   12   1
bob    123  2
andy   34   3
jack   23   4

etc. It has a total of 41 million entries. 等等。总共有4100万个条目。 SNO is my primary key of continuous INT values. SNO是连续INT值的主键。 When I run a query to select a particular SNO, it works lightning fast. 当我运行查询以选择特定的SNO时,它的运行速度很快。 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. 请注意,名称不必是唯一的,并且很可能重复使用,但具有不同的ID。 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? 有什么方法可以索引“文本”数据类型的“名称”,从而与访问“ int” SNO一样提高访问性能?

Try to make enough space for the index in memory. 尝试为内存中的索引留出足够的空间。 The shared_buffers setting can be helpful in this. shared_buffers设置可以对此有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM