Results 1 to 2 of 2
  1. #1
    Join Date
    May 2009

    Unanswered: Would clustering improve these lookups?

    Hi all, I believe I understand the principle of clustering pretty well - physically reordering the records on the disk so the related rows, likely to be relevant to the same query, are more likely to be on the same page (rather than scattered) thereby reducing page lookups from the disk for queries utilizing that index.

    I typically read people saying that clustered indexes are most useful in range lookups - eg. date ranges or number ranges (eg. "where mydate between '2001/01/01' and '2001/01/03'").

    Would I be correct in saying that it could help improve performance in child/parent tables as well? For example, if the parent table "invoices" had a child table "invoice_items" (with foreign key "invoice_id"), then clustering the "invoice_items" table on field "invoice_id" would increase the likelihood that all the invoice_items rows for a specific invoices row would be stored on a single page.

    Sound about right?

    Thanks in advance,
    Last edited by brendan.hill; 06-18-09 at 04:44.

  2. #2
    Join Date
    May 2009
    While you might see some improvement by clustering, it's not going to give you what you're looking for by itself. In fact, since you're pulling a single row at a time, I doubt it will do anything, except for reports.

    You will get better improvement by moving one of the tables to a second physical disk.

    Unfortunately, Postgres doesn't seem to support it, but something like Informix's FRAGMENT BY, or SQL Server's DPV's would give you rocking performance. Alas, maybe next year.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts