Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 16865 invoked from network); 28 Mar 2006 19:00:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 28 Mar 2006 19:00:26 -0000 Received: (qmail 3810 invoked by uid 500); 28 Mar 2006 19:00:25 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 3714 invoked by uid 500); 28 Mar 2006 19:00:24 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 3703 invoked by uid 99); 28 Mar 2006 19:00:24 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Mar 2006 11:00:24 -0800 X-ASF-Spam-Status: No, hits=1.4 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: 32.97.110.149 is neither permitted nor denied by domain of Stan.Bradbury@gmail.com) Received: from [32.97.110.149] (HELO e31.co.us.ibm.com) (32.97.110.149) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Mar 2006 11:00:22 -0800 Received: from westrelay02.boulder.ibm.com (westrelay02.boulder.ibm.com [9.17.195.11]) by e31.co.us.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id k2SJ01Sw008156 for ; Tue, 28 Mar 2006 14:00:01 -0500 Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by westrelay02.boulder.ibm.com (8.12.10/NCO/VER6.8) with ESMTP id k2SIupKX252528 for ; Tue, 28 Mar 2006 11:56:51 -0700 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.12.11/8.13.3) with ESMTP id k2SJ01i7018179 for ; Tue, 28 Mar 2006 12:00:01 -0700 Received: from [127.0.0.1] (bradbury-lt1.usca.ibm.com [9.72.133.41]) by d03av04.boulder.ibm.com (8.12.11/8.12.11) with ESMTP id k2SIxxEI017421 for ; Tue, 28 Mar 2006 12:00:01 -0700 Message-ID: <44298770.50009@gmail.com> Date: Tue, 28 Mar 2006 10:58:56 -0800 From: Stanley Bradbury User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Derby Discussion Subject: Re: How do I tell whether a table has unused space or not? References: <4428A545.7060006@amberpoint.com> In-Reply-To: <4428A545.7060006@amberpoint.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Bryan Pendleton wrote: > Recently, I had a table which was able to substantially > benefit from compression. I determined that I had a problem > by setting derby.logQueryPlan to TRUE, running a "select *" > query against the table, and then viewing the page and > row count statistics that were emitted in the query plan, > where I saw that the optimizer was expecting to process many > more pages than I thought needed to be in the table. > > Compressing the table made my problem go away, and the > optimizer returned to choosing my desired query plans. > > But I am left with the desire for an easier way to figure > out whether my table needs compression or not. > > I tried reading the manual, for example I found > http://db.apache.org/derby/docs/10.1/adminguide/cadminspace21579.html > but that page does not offer any clear way to tell whether a > table needs to be compressed or not. > > What is the preferred way to decide whether a table has unused space? > > thanks, > > bryan > > Hi Bryan - You can use the diagnostic method SpaceTable to find out how many pages are allocated to a table and obtain an estimate of how much space might be saved by running the COMPRESS_TABLE procedure (column: ESTIMSPACESAVING). The method takes a SCHEMA name (optional) and a TABLE name. The query looks like this: select * from NEW org.apache.derby.diag.SpaceTable('SCHEMANAME', 'MY_TABLENAME') as ST; EXAMPLE: ij> select * from NEW org.apache.derby.diag.SpaceTable('SYS','SYSTABLES') as ST; CONGLOMERATENAME |ISIND&|NUMALLOCATEDPAGES |NUMFREEPAGES |NUMUNFILLEDPAGES |PAGESIZE |ESTIMSPACESAVING ------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------- SYSTABLES_INDEX1 |1 |1 |0 |1 |4096 |0 SYSTABLES_INDEX2 |1 |1 |0 |1 |4096 |0 SYSTABLES |0 |1 |0 |1 |4096 |0 3 rows selected You might be interested in following the enhancement request *DERBY-512 *this identifies the need to reclaim space automatically so COMPRESS_TABLE is no longer needed.