我在测试数据库中插入了1万行。我正在使用一些样本索引进行性能测试。目前,我在主键上创建了一个聚集索引,以查看完全匹配过滤器是否会有所作为,并且仍然需要800毫秒以上的时间来检索此结果:
注意:这只是高级示例测试,因此所有varchar列都填充有> 100。
version: '3.4'
services:
webapp:
image: mcr.microsoft.com/dotnet/core/samples:aspnetapp
ports:
- 80
- 443
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+:443;http://+:80
- ASPNETCORE_Kestrel__Certificates__Default__Password=password
- ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx
volumes:
- ~/.aspnet/https:/https:ro
CREATE UNIQUE INDEX people_idx ON people (id);
CLUSTER people USING people_idx;
select * from people
where id = 2;
我正确地考虑了吗?
我更新了群集索引以添加到CREATE TABLE "people" (
id SERIAL PRIMARY KEY,
first_name varchar(255) default NULL,
last_name varchar(255) default NULL,
email varchar(255) default NULL,
created_date varchar(255),
phone varchar(100) default NULL,
customer_id integer NULL
);
:
last_name
分析输出如下:
CREATE INDEX people_idx ON people (last_name);
EXPLAIN ANALYZE select * from people
where first_name = 'Sophia';
EXPLAIN ANALYZE select * from people
where last_name ILIKE 'd%';