Received: from c2bapps8.btconnect.com (unknown [193.113.209.32]) by postgresql.org (Postfix) with SMTP id 96F184763BE for ; Fri, 5 Apr 2002 16:37:06 -0500 (EST) Received: from localhost (actually host host213-122-124-1.in-addr.btopenworld.com) by c2bapps8 with SMTP-CUST (XT-PP) with ESMTP; Fri, 5 Apr 2002 22:37:06 +0100 Date: Fri, 5 Apr 2002 22:39:54 +0000 Mime-Version: 1.0 (Apple Message framework v481) Content-Type: text/plain; charset=US-ASCII; format=flowed Subject: intersect performance (PG 7.1.3 vs 7.2) From: d_nardini@btconnect.com To: pgsql-sql@postgresql.org Content-Transfer-Encoding: 7bit Message-Id: <0CBD3E12-48E6-11D6-8010-0030654E696C@btconnect.com> X-Mailer: Apple Mail (2.481) X-Archive-Number: 200204/71 X-Sequence-Number: 7336 Hi, I'm running the following statement on a (development) Mac OS X (PG 7.2) box and on a (production) RedHat 7.0 (PG 7.1.3) box. On the OS X it's performing very well ... on RH it's VERY SLOW, with CPU utilization hitting 90%+ (on OS X it hardly exceeds 2%). BTW - replacing 'intersect' with 'union' in the SQL behaves the same. (RH 7.0 box has 4x the amount of memory and CPU power - plenty of spare capacity). Do I need to upgrade the RH box with 7.2 (have there been significant enhancements in this area ?), or have I missed something obvious ? Any comments / advice welcome ! SQL statement : select i.master_reference from image i, image_keyword ik, keyword k where k.keyword = 'pen' and ik.keyword_id = k.keyword_id and i.image_id = ik.image_id intersect select i.master_reference from image i, image_keyword ik, keyword k where k.keyword = 'cheque' and ik.keyword_id = k.keyword_id and i.image_id = ik.image_id intersect select i.master_reference from image i, image_keyword ik, keyword k where k.keyword = 'purchase' and ik.keyword_id = k.keyword_id and i.image_id = ik.image_id order by master_reference limit 12, 0; DEFINITIONS statements : drop table image; drop sequence image_seq; create sequence image_seq; create table image ( image_id bigint not null default nextval('image_seq') primary key, artist_id integer not null default '0' ); drop table image_keyword; create table image_keyword ( image_id bigint not null default '0', keyword_id bigint not null default '0' ); create index image_keyword_image_id_ix on image_keyword (image_id); create index image_keyword_keyword_id_ix on image_keyword (keyword_id); drop table keyword; drop sequence keyword_seq; create sequence keyword_seq; create table keyword ( keyword_id bigint not null default nextval('keyword_seq') primary key, keyword varchar(50) not null unique ); create index keyword_keyword_ix on keyword (keyword); approx number of records/rows in the above tables : image = 15000 image_keyword = 600000 keyword = 40000