Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id B6982AF82E7 for ; Mon, 9 Jan 2012 10:41:30 -0400 (AST) Received: from mail2.sdb.it ([85.37.147.67]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RkGPc-0007nL-IJ for pgsql-admin@postgresql.org; Mon, 09 Jan 2012 14:41:30 +0000 Received: by mail2.sdb.it (Postfix, from userid 500) id AEAFD803C; Mon, 9 Jan 2012 15:41:09 +0100 (CET) Received: from geronimo.sdb.it (geronimo.sdb.it [10.101.1.20]) by mail2.sdb.it (Postfix) with ESMTP id A8F128028 for ; Mon, 9 Jan 2012 15:41:09 +0100 (CET) Received: from mailtech.sdb.it (localhost [127.0.0.1]) by geronimo.sdb.it (Postfix) with ESMTP id 62C1C3805AF for ; Mon, 9 Jan 2012 15:40:59 +0100 (CET) Received: from [10.118.101.88] (silviob.sdb.it [10.118.101.88]) by mailtech.sdb.it (Postfix) with ESMTP id 44D0460063 for ; Mon, 9 Jan 2012 15:41:09 +0100 (CET) Message-ID: <4F0AFC85.5050908@tech.sdb.it> Date: Mon, 09 Jan 2012 15:41:09 +0100 From: Silvio Brandani User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.9.2.25) Gecko/20111213 Thunderbird/3.1.17 MIME-Version: 1.0 To: pgsql-admin@postgresql.org Subject: problem on table statistics Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Private-Material: Please read notice X-Pg-Spam-Score: 0.8 (/) X-Archive-Number: 201201/39 X-Sequence-Number: 38951 In the last few hours we get a problem with following query in Production database : select * from "001".mov_con where number in ( select number from "001".mov_con where abs(amount-total_amo)>0.1) ; The correct plan should be QUERY PLAN ----------------------------------------------------------------------------------------------------- Nested Loop (cost=541763.01..584606.03 rows=1249640 width=360) -> HashAggregate (cost=541763.01..541807.55 rows=4454 width=10) -> Index Scan using mov_con_x9 on mov_con t2 (cost=0.00..538639.38 rows=1249452 width=10) Filter: (abs((amount - total_amo)) > 0.1::double precision) -> Index Scan using mov_con_pkey on mov_con t1 (cost=0.00..6.10 rows=281 width=360) Index Cond: (t1.number = t2.number) (6 rows) instead we get the following WRONG one: QUERY PLAN ----------------------------------------------------------------------------------------------- Nested Loop IN Join (cost=0.00..52906.16 rows=117499 width=620) -> Index Scan using mov_con_x10 on mov_con t1 (cost=0.00..52483.90 rows=352486 width=620) -> Index Scan using mov_con_x10 on mov_con t2 (cost=0.00..0.72 rows=3 width=11) Index Cond: (t2.number = t1.number) Filter: (abs((t2.amount - t2.total_amo)) > 0.1::double precision) So I go to see statistics and try to change the default_statistics_target from 10 to 100 , reload the configuration and vacuum the table and the result is that while the other tables have now 100 values on pg_stats the mov_con table still have the same values SELECT * FROM pg_stats WHERE tablename='mov_con' AND attname='number' ; So there is something wrong with table statistics. How can I reset the pg_statistics for this table??? Any comment higly appreciated. -- Silvio Brandani --- Utilizziamo i dati personali che la riguardano esclusivamente per nostre finalitą amministrative e contabili, anche quando li comunichiamo a terzi. Informazioni dettagliate, anche in ordine al Suo diritto di accesso e agli altri Suoi diritti, sono riportate alla pagina http://www.savinodelbene.com/privacy.html Se avete ricevuto questo messaggio per errore Vi preghiamo di ritornarlo al mittente eliminandolo assieme agli eventuali allegati, ai sensi art. 616 codice penale http://www.savinodelbene.com/privacy/codice_penale_616.html L'Azienda non si assume alcuna responsabilitą giuridica qualora pervengano da questo indirizzo messaggi estranei all'attivitą lavorativa o contrari a norme. --