Hi Aaron,

> -----Original Message-----
> [mailto:[EMAIL PROTECTED] Behalf Of 
> Aaron Werman
> Sent: vrijdag 2 april 2004 13:57
> another thing that I have all over the place is a hierarchy:
> index on grandfather_table(grandfather)
> index on father_table(grandfather, father)
> index on son_table(grandfather, father, son)

It depends on your data-distribution, but I find that in almost all cases it's 
beneficial to have your indexes the other way round in such cases:

index on grandfather_table(grandfather)
index on father_table(father, grandfather)
index on son_table(son, father, grandfather)

That usually gives a less common, more selective value at the start of the index, 
making the initial selection in the index smaller.

And AFAIK I don't have to rewrite my queries for that; the planner doesn't care about 
the order of expressions in the query that are on the same level.

That said, I tend to use 'surrogate keys'; keys generated from sequences or 
auto-number columns for my tables. It makes the tables less readable, but the indexes 
remain smaller.



---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Reply via email to