Denormalized categories

I wanted to add categories to my table. For speed and simplicity, I just added five varchar fields to the table: cat0..cat4. Instead of a big OR-expression in my WHERE clause I did this:

SELECT *
FROM TABLE
WHERE @Category IN (cat0,cat1,cat2,cat3,cat4)

The key insight for me was you can add fields in the comma-seperated list, instead of values. And it’s more readable too. But it has the same execution plan as the “big OR”-variant.

 
blog\denormalized_categories.txt · Last modified: 2008-12-02T09:34 by doekman
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki