pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rajesh Kumar Mallah <mallah.rajesh@gmail.com>
To: Lista Postgres <pgsql-admin@postgresql.org>
Subject: Adding a column with default value possibly corrupting a functional index.
Date: Sat, 16 Dec 2006 21:54:36 +0530
Message-ID: <a97c77030612160824w102c2326n23706171ba8a6b3a@mail.gmail.com> (raw)

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_masterwhere  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_masterwhere  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_masterwhere  upper(
general.cat_url(category_id)::text) = 'AGRICULTURE';
+-------------+
| category_id |
+-------------+
|           1 |
+-------------+
(1 row)

view thread (8+ messages)  latest in thread

Message-ID: <a97c77030612160824w102c2326n23706171ba8a6b3a@mail.gmail.com>
Permalink:  ../a97c77030612160824w102c2326n23706171ba8a6b3a@mail.gmail.com/
Also on:    postgresql.org/message-id/a97c77030612160824w102c2326n23706171ba8a6b3a@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: mallah.rajesh@gmail.com
  Subject: Re: Adding a column with default value possibly corrupting a functional index.
  In-Reply-To: <a97c77030612160824w102c2326n23706171ba8a6b3a@mail.gmail.com>
  References: <a97c77030612160824w102c2326n23706171ba8a6b3a@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox