AWS RDS Postgres 查询性能问题

AWS RDS Postgres query performance issue

我在 m1/small 实例上的 AWS RDS 运行 上有一个 Postgres 数据库。它有一个 table,有 4000 万行。当我这样查询时:

select * from business where name = 'Pizza House'

需要几分钟才能收到回复。我可以做些什么来提高数据库的查询性能?

这是用于创建此 table 的创建命令:

CREATE TABLE public.business
(
  id integer NOT NULL DEFAULT nextval('business_id_seq'::regclass),
  name character varying,
  city character varying,
  state character varying,
  zip character varying,
  is_claimed integer,
  ...,
  ...,
  CONSTRAINT business_pkey PRIMARY KEY (id)
)
WITH (
  OIDS=FALSE
);
ALTER TABLE public.business
  OWNER TO administrator;

当我运行:

explain select * from business where name = 'Pizza House'

我得到:

1, "Seq Scan on business  (cost=0.00..1481123.57 rows=22 width=636)"
2, "  Filter: ((name)::text = 'Pizza House'::text)"

想法?

您很可能希望在 name 列中放置一个 index

但作为一个整体,您应该阅读索引。这是一个很好的资源:

http://use-the-index-luke.com/