Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 643731337990 for ; Wed, 23 Mar 2011 03:23:27 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 24796-07 for ; Wed, 23 Mar 2011 06:23:18 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp150.dfw.emailsrvr.com (smtp150.dfw.emailsrvr.com [67.192.241.150]) by mail.postgresql.org (Postfix) with ESMTP id 6E2741337BB4 for ; Wed, 23 Mar 2011 03:23:18 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp5.relay.dfw1a.emailsrvr.com (SMTP Server) with ESMTP id C0EFD190031; Wed, 23 Mar 2011 02:23:16 -0400 (EDT) X-Virus-Scanned: OK Received: by smtp5.relay.dfw1a.emailsrvr.com (Authenticated sender: adarsh.sharma-AT-orkash.com) with ESMTPSA id 8808658C09 for ; Wed, 23 Mar 2011 02:23:15 -0400 (EDT) Message-ID: <4D899301.7070301@orkash.com> Date: Wed, 23 Mar 2011 11:58:17 +0530 From: Adarsh Sharma User-Agent: Thunderbird 2.0.0.22 (X11/20090625) MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Reason of Slowness of query Content-Type: multipart/alternative; boundary="------------000504070507010003080800" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-1.9, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7 X-Spam-Level: X-Archive-Number: 201103/253 X-Sequence-Number: 42932 This is a multi-part message in MIME format. --------------000504070507010003080800 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Dear all, I have 2 tables in my database name clause2( 4900 MB) & page_content(1582 MB). My table definations are as : *page_content :- *CREATE TABLE page_content ( content_id integer, wkb_geometry geometry, link_level integer, isprocessable integer, isvalid integer, isanalyzed integer, islocked integer, content_language character(10), url_id integer, publishing_date character(40), heading character(150), category character(150), crawled_page_url character(500), keywords character(500), dt_stamp timestamp with time zone, "content" character varying, crawled_page_id bigint, id integer ) WITH ( OIDS=FALSE ); *Indexes on it :-* CREATE INDEX idx_page_id ON page_content USING btree (crawled_page_id); CREATE INDEX idx_page_id_content ON page_content USING btree (crawled_page_id, content_language, publishing_date, isprocessable); CREATE INDEX pgweb_idx ON page_content USING gin (to_tsvector('english'::regconfig, content::text)); *clause 2:- *CREATE TABLE clause2 ( id bigint NOT NULL DEFAULT nextval('clause_id_seq'::regclass), source_id integer, sentence_id integer, clause_id integer, tense character varying(30), clause text, CONSTRAINT pk_clause_demo_id PRIMARY KEY (id) )WITH ( OIDS=FALSE); *Indexes on it : *CREATE INDEX idx_clause2_march10 ON clause2 USING btree (id, source_id);* *I perform a join query on it as : * explain analyze select distinct(p.crawled_page_id) from page_content p , clause2 c where p.crawled_page_id != c.source_id ; *What it takes more than 1 hour to complete. As I issue the explain analyze command and cannot able to wait for output but I send my explain output as : QUERY PLAN -------------------------------------------------------------------------------------------------------- Unique (cost=927576.16..395122387390.13 rows=382659 width=8) -> Nested Loop (cost=927576.16..360949839832.15 rows=13669019023195 width=8) Join Filter: (p.crawled_page_id <> c.source_id) -> Index Scan using idx_page_id on page_content p (cost=0.00..174214.02 rows=428817 width=8) -> Materialize (cost=927576.16..1370855.12 rows=31876196 width=4) -> Seq Scan on clause2 c (cost=0.00..771182.96 rows=31876196 width=4) (6 rows) Please guide me how to make the above query run faster as I am not able to do that. Thanks, Adarsh * * --------------000504070507010003080800 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Dear all,

I have 2 tables in my database name clause2( 4900 MB) & page_content(1582 MB).

My table definations are as :

page_content :-

CREATE TABLE page_content
(
  content_id integer,
  wkb_geometry geometry,
  link_level integer,
  isprocessable integer,
  isvalid integer,
  isanalyzed integer,
  islocked integer,
  content_language character(10),
  url_id integer,
  publishing_date character(40),
  heading character(150),
  category character(150),
  crawled_page_url character(500),
  keywords character(500),
  dt_stamp timestamp with time zone,
  "content" character varying,
  crawled_page_id bigint,
  id integer
)
WITH (
  OIDS=FALSE
);

Indexes on it :-
CREATE INDEX idx_page_id  ON page_content  USING btree  (crawled_page_id);
CREATE INDEX idx_page_id_content   ON page_content  USING btree  (crawled_page_id, content_language, publishing_date, isprocessable);
CREATE INDEX pgweb_idx  ON page_content   USING gin   (to_tsvector('english'::regconfig, content::text));

clause 2:-
CREATE TABLE clause2
(
  id bigint NOT NULL DEFAULT nextval('clause_id_seq'::regclass),
  source_id integer,
  sentence_id integer,
  clause_id integer,
  tense character varying(30),
  clause text,
  CONSTRAINT pk_clause_demo_id PRIMARY KEY (id)
)WITH ( OIDS=FALSE);

Indexes on it :

CREATE INDEX idx_clause2_march10
  ON clause2
  USING btree
  (id, source_id);

I perform a join query on it as :

 explain analyze select distinct(p.crawled_page_id) from page_content p , clause2  c where p.crawled_page_id != c.source_id ;

What it takes more than 1 hour to complete. As I issue the explain analyze command and cannot able to wait for output but I send my explain output as :
                                             QUERY PLAN                                              
--------------------------------------------------------------------------------------------------------
 Unique  (cost=927576.16..395122387390.13 rows=382659 width=8)
   ->  Nested Loop  (cost=927576.16..360949839832.15 rows=13669019023195 width=8)
         Join Filter: (p.crawled_page_id <> c.source_id)
         ->  Index Scan using idx_page_id on page_content p  (cost=0.00..174214.02 rows=428817 width=8)
         ->  Materialize  (cost=927576.16..1370855.12 rows=31876196 width=4)
               ->  Seq Scan on clause2 c  (cost=0.00..771182.96 rows=31876196 width=4)
(6 rows)


Please guide me how to make the above query run faster as I am not able to do that.


Thanks, Adarsh







--------------000504070507010003080800--