From: | Eric Brown <eric(dot)brown(at)propel(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | What's faster |
Date: | 2004-12-11 02:15:50 |
Message-ID: | 939820DC-4B1A-11D9-A5B2-000A95C7176C@propel.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Option 1:
create table a (id serial, hosts text[]);
OR
Option 2:
create table a (id serial);
create table hosts (id int references a, host text);
Table 'a' will have about 500,000 records. There will probably be about
20 reads for every write. Each id has approximately 1.1 hosts. If I use
the array (option 1), I'll have to loop over the elements of the array
to see if I have a match when querying a given id. This isn't hard, but
it means that SELECT will always return 1 record when, in option 2, it
might return 0 records and only have accessed the indexes.
Given the indexes that will be built and disk pages used (cached or
otherwise), which mechanism would be faster for searching.
From | Date | Subject | |
---|---|---|---|
Next Message | Stephan Szabo | 2004-12-11 02:28:38 | Re: Query is not using index when it should |
Previous Message | itamar | 2004-12-11 02:07:26 | relation "table" does not exist |