+ linkend="indexes-partial-ex4"/>.
+
+
Do Not Use Partial Indexes as a Substitute for Partitioning
+
+ You might be tempted to create a large set of non-overlapping partial
+ indexes, for example
+
+CREATE INDEX mytable_cat_1 ON mytable (data) WHERE category = 1;
+CREATE INDEX mytable_cat_2 ON mytable (data) WHERE category = 2;
+CREATE INDEX mytable_cat_3 ON mytable (data) WHERE category = 3;
+...
+CREATE INDEX mytable_cat_N ON mytable (data) WHERE category = N;
+
+
+ This is a bad idea! Almost certainly, you'll be better off with a
+ single non-partial index, declared like
+
+CREATE INDEX mytable_cat_data ON mytable (category, data);
+
+
+ (Put the category column first, for the reasons described in
+ .) While a search in this larger
+ index might have to descend through a couple more tree levels than a
+ search in a smaller index, that's almost certainly going to be cheaper
+ than the planner effort needed to select the appropriate one of the
+ partial indexes. The core of the problem is that the system does not
+ understand the relationship among the partial indexes, and will
+ laboriously test each one to see if it's applicable to the current
+ query.
+
+
+ If your table is large enough that a single index really is a bad idea,
+ you should look into using partitioning instead (see
+ ). With that mechanism, the system
+ does understand that the tables and indexes are non-overlapping, so
+ far better performance is possible.
+
+
+
More information about partial indexes can be found in
linkend="ston89b"/>, , and