Adding a column with default value possibly corrupting a functional index.
От | Rajesh Kumar Mallah |
---|---|
Тема | Adding a column with default value possibly corrupting a functional index. |
Дата | |
Msg-id | a97c77030612160824w102c2326n23706171ba8a6b3a@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: Adding a column with default value possibly corrupting a functional index.
|
Список | pgsql-admin |
Hi,
I have an index on upper(general.cat_url(category_id)) on a table.
when i add a column *with* default value , a query that previously
used to give result does not give results anymore. REINDEX'ing the
table produces correct result. if no default value is giving while adding
the column the query continues to give proper result.
Regds
mallah.
tradein_clients=> SELECT category_id from general.web_category_master where upper(general.cat_url(category_id)::text) = 'AGRICULTURE';
+-------------+
| category_id |
+-------------+
| 1 |
+-------------+
(1 row)
tradein_clients=> explain SELECT category_id from general.web_category_master where upper(general.cat_url(category_id)::text) = 'AGRICULTURE';
+-------------------------------------------------------------------------------------------------------------+
| QUERY PLAN |
+-------------------------------------------------------------------------------------------------------------+
| Index Scan using web_category_master_upper_cat_url on web_category_master (cost=0.00..8.02 rows=1 width=4) |
| Index Cond: (upper((general.cat_url(category_id))::text) = 'AGRICULTURE'::text) |
+-------------------------------------------------------------------------------------------------------------+
(2 rows)
tradein_clients=> ALTER TABLE general.web_category_master add test_id int default 0;
ALTER TABLE
tradein_clients=> SELECT category_id from general.web_category_master where upper(general.cat_url (category_id)::text) = 'AGRICULTURE';
+-------------+
| category_id |
+-------------+
+-------------+
(0 rows)
tradein_clients=> REINDEX TABLE general.web_category_master;
REINDEX
tradein_clients=> SELECT category_id from general.web_category_master where upper(general.cat_url(category_id)::text) = 'AGRICULTURE';
+-------------+
| category_id |
+-------------+
| 1 |
+-------------+
(1 row)
I have an index on upper(general.cat_url(category_id)) on a table.
when i add a column *with* default value , a query that previously
used to give result does not give results anymore. REINDEX'ing the
table produces correct result. if no default value is giving while adding
the column the query continues to give proper result.
Regds
mallah.
tradein_clients=> SELECT category_id from general.web_category_master where upper(general.cat_url(category_id)::text) = 'AGRICULTURE';
+-------------+
| category_id |
+-------------+
| 1 |
+-------------+
(1 row)
tradein_clients=> explain SELECT category_id from general.web_category_master where upper(general.cat_url(category_id)::text) = 'AGRICULTURE';
+-------------------------------------------------------------------------------------------------------------+
| QUERY PLAN |
+-------------------------------------------------------------------------------------------------------------+
| Index Scan using web_category_master_upper_cat_url on web_category_master (cost=0.00..8.02 rows=1 width=4) |
| Index Cond: (upper((general.cat_url(category_id))::text) = 'AGRICULTURE'::text) |
+-------------------------------------------------------------------------------------------------------------+
(2 rows)
tradein_clients=> ALTER TABLE general.web_category_master add test_id int default 0;
ALTER TABLE
tradein_clients=> SELECT category_id from general.web_category_master where upper(general.cat_url (category_id)::text) = 'AGRICULTURE';
+-------------+
| category_id |
+-------------+
+-------------+
(0 rows)
tradein_clients=> REINDEX TABLE general.web_category_master;
REINDEX
tradein_clients=> SELECT category_id from general.web_category_master where upper(general.cat_url(category_id)::text) = 'AGRICULTURE';
+-------------+
| category_id |
+-------------+
| 1 |
+-------------+
(1 row)
В списке pgsql-admin по дате отправления: