From: Frank B. <fb...@fo...> - 2003-12-04 15:10:20
|
Hallo, getting at the lenght of a result with SQLResult's count() finction issues a "select count(*) from X". In my PostgreSQL table, this is quite expensive, and I am wondering, why. Analyzing the query shows, that no index is used: => explain SELECT count(*) from normal; NOTICE: QUERY PLAN: Aggregate (cost=3512.10..3512.10 rows=1 width=0) -> Seq Scan on normal (cost=0.00..3371.28 rows=56328 width=0) My table looks like this with pg_dump: CREATE SEQUENCE "normal_id_seq" start 1 increment 1 maxvalue 9223372036854775807 minvalue 1 cache 1; CREATE TABLE "normal" ( "id" integer DEFAULT nextval('"normal_id_seq"'::text) NOT NULL, "description" text, "format" character varying(16), "artist" character varying(200), "category" character varying(100), "title" character varying(200), "price" double precision, "label" character varying(200), "catalog" character varying(20), "datum" timestamp with time zone, "special" character varying(20), Constraint "normal_pkey" Primary Key ("id") ); ciao -- Frank Barknecht _ ______footils.org__ |