Re: Better index stategy for many fields with few values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




- My items table:
code int              -- can take one of 100 values
property varchar(250) -- can take one of 5000 values
param01 char(10)      -- can take one of 10 values
param02 char(10)      -- can take one of 10 values
...
[ 20 similar columns }
...
parama20 char(10)     -- can take one of 10 values

Instead of 20 columns, you could instead use a "param" field containing an array of 20 TEXT fields. Then create a simple index on (code, param) and SELECT WHERE code BETWEEN ... AND param = '{P,G,....,C}'

If you don't want to modify your structure, you can create a functional index on an array {param1...param20}, but your queries will be a bit uglier.


[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux