Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 0CB921337B96 for ; Fri, 4 Feb 2011 16:38:05 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 81935-09 for ; Fri, 4 Feb 2011 20:37:57 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp2.peak6.com (smtp2.peak6.com [38.98.137.9]) by mail.postgresql.org (Postfix) with ESMTP id 4DB8B1337B95 for ; Fri, 4 Feb 2011 16:37:56 -0400 (AST) X-AuditID: 0a02cb1e-b7bf8ae00000096d-09-4d4c63a46a7d Message-ID: <4D4C63A4.6090109@peak6.com> Date: Fri, 4 Feb 2011 14:37:56 -0600 From: Shaun Thomas Reply-To: sthomas@peak6.com Organization: Peak6 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.7) Gecko/20100720 Lightning/1.0b2 Thunderbird/3.1.1 MIME-Version: 1.0 To: felix CC: Scott Marlowe , "pgsql-performance@postgresql.org" Subject: Re: Really really slow select count(*) References: <4D4C138C.7010304@2ndquadrant.com> <4D4C1555.40209@peak6.com> <4D4C2AC3.5020804@peak6.com> <4D4C3BCA.5010808@peak6.com> <4D4C46C2.1080108@peak6.com> <4D4C5AE6.4030101@peak6.com> In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed content-transfer-encoding: 7bit X-Brightmail-Tracker: AAAAAQAAAZE= X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201102/220 X-Sequence-Number: 42358 On 02/04/2011 02:14 PM, felix wrote: > oh and there in the footnotes to django they say "dont' forget to run > the delete expired sessions management every once in a while". > thanks guys. Oh Django... :) > it won't run now because its too big, I can delete them from psql though You might be better off deleting the inverse. You know, start a transaction, select all the sessions that *aren't* expired, truncate the table, insert them back into the session table, and commit. BEGIN; CREATE TEMP TABLE foo_1 AS SELECT * FROM django_session WHERE date_expired < CURRENT_DATE; TRUNCATE django_session; INSERT INTO django_session SELECT * from foo_1; COMMIT; Except I don't actually know what the expired column is. You can figure that out pretty quick, I assume. That'll also have the benefit of cleaning up the indexes and the table all at once. If you just do a delete, the table won't change at all, except that it'll have less active records. > well just think how sprightly my website will run tomorrow once I fix > these. Maybe. :) -- Shaun Thomas OptionsHouse | 141 W. Jackson Blvd. | Suite 800 | Chicago IL, 60604 312-676-8870 sthomas@peak6.com ______________________________________________ See http://www.peak6.com/email_disclaimer.php for terms and conditions related to this email