From: | DelGurth <delgurth(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Queries joining views |
Date: | 2006-08-21 20:57:52 |
Message-ID: | 10268b3e0608211357n4f0e8b99u689803c079af25d7@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
>
> Alban Hertroys <alban ( at ) magproductions ( dot ) nl> writes:
> > Is there a trick to make this work a bit faster?
>
> Have you really shown us the right queries for those explain results?
> I don't see where the second plan is testing "dir <> 1" at all.
> It looks like the first one is faster because it's using a partial
> index that has predicate dir <> 1, while the second one is using
> a much larger full index. But I don't see where the second plan
> is applying that restriction, so I wonder if you forgot it in the
> query.
>
> regards, tom lane
He has really shown the right queries. But I see the table definition if
mm_insrel_table (including the indexes) is not in the e-mail, so you don't
see why the dir <> 1 is not in the query plan. Here is the table definition,
with the indexes. As you can see we tried some indexes, to see if we could
get the queries on the views to become faster.
zorgweb_solaris=> \d mm_insrel_table
Table "public.mm_insrel_table"
Column | Type | Modifiers
---------+---------+-----------
number | integer | not null
snumber | integer | not null
dnumber | integer | not null
rnumber | integer | not null
dir | integer |
Indexes:
"mm_insrel_table_pkey" PRIMARY KEY, btree (number)
"mm_insrel_dir_not_one_idx" btree (dnumber, snumber) WHERE dir <> 1
"mm_insrel_dnumber_dir_not_one_idx" btree (dnumber) WHERE dir <> 1
"mm_insrel_full_idx" btree (snumber, dnumber, rnumber, dir) WHERE dir <>
1
"mm_insrel_relation_idx" btree (snumber, dnumber, rnumber)
Foreign-key constraints:
"mm_insrel_table_dnumber_fkey" FOREIGN KEY (dnumber) REFERENCES
mm_object(number)
"mm_insrel_table_rnumber_fkey" FOREIGN KEY (rnumber) REFERENCES
mm_object(number)
"mm_insrel_table_snumber_fkey" FOREIGN KEY (snumber) REFERENCES
mm_object(number)
I hope this explains you why the dir <> 1 is not in the view query. Why the
other query plan thinks it needs to recheck the condition is not clear to
me, but I'm not an expert on PostgreSQL query plans.
Regards,
Wessel van Norel
From | Date | Subject | |
---|---|---|---|
Next Message | Arturo Perez | 2006-08-21 21:06:07 | [8.1.4] Create index on timestamp fails |
Previous Message | John D. Burger | 2006-08-21 19:10:49 | Re: Queries joining views |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2006-08-21 21:32:33 | Re: Queries joining views |
Previous Message | mdean | 2006-08-21 20:36:55 | Re: ISBN/ISSN/ISMN/EAN13 module |