From: | Dima Tkach <dmitry(at)openratings(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Subject: | Re: Index not used with IS NULL |
Date: | 2003-02-16 20:37:17 |
Message-ID: | 3E4FF67D.9050003@openratings.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
>>A row in the table is a tree node. A node can have one parent, ot no
>>parent at all.
>
>
> You're better off making the root node link to itself (compare handling
> of /.. in a Unix filesystem). NULL parent link does not mean "has no
> parent", it means "parent is unknown".
>
Great idea! I'll do that. Thanks!
What about another example:
create table user
(
id serial primary key,
login text not null unique
);
create table tag_set
(
id serial primay key,
tag text not null unique,
data text not null,
userid int references users on delete cascade on update cascade
);
The idea is that 'tags' may be user-specific or user-independent - so
that to get a set of tags for a given user, I would do
select tag,data from tag_set where userid is null or userid=?
with my 'workaround' solution I do
select tag,data from tag_set where userid==null or userid=?
(where '==' is my special non-strict operator)
to force both parts of the criteria to use the index
Any ideas how to do this better (again, other than creating a dummy user
with id 0)?
I'll apppreciate any suggestions...
Thanks a lot!
Dima
From | Date | Subject | |
---|---|---|---|
Next Message | Oliver Elphick | 2003-02-16 20:47:25 | Re: inheritance |
Previous Message | Tom Lane | 2003-02-16 19:36:09 | Re: Aggregates with non-commutative transition functions |