Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZWRpl-0005Om-5t for pgsql-performance@arkaria.postgresql.org; Mon, 31 Aug 2015 16:21:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZWRpk-0007xO-4x for pgsql-performance@arkaria.postgresql.org; Mon, 31 Aug 2015 16:21:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZWRo6-00061f-U7 for pgsql-performance@postgresql.org; Mon, 31 Aug 2015 16:19:42 +0000 Received: from mail-wi0-f179.google.com ([209.85.212.179]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1ZWRo3-0005xO-4I for pgsql-performance@postgresql.org; Mon, 31 Aug 2015 16:19:42 +0000 Received: by wibz8 with SMTP id z8so5449046wib.1 for ; Mon, 31 Aug 2015 09:19:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=ra9yl6yn5muZ5YRBJTR7SCUdO7euCcYe52kiLC98c00=; b=Fy1OzDSFGEDbncOHxS7TxP6xqszcBEh3i3tN+KmRpfZ1T1ezKzclu+XfQIBNOj/dzU EG0uGtO6rzKjbm9GATni1o9cniU9V2d7bDw3nvuJBBe9iatYtBQXFMBJ0uawgauB4MOJ qTKY4eaFcDV7yyF/qtMHjZVPfsPRlizakCVwyV59kFbxce7IUOkEu/7f3A+vHzV6GXFa APRF/gjzyz59syGxiLE5ZxXtNcngDWydMmlufUDSE01kPkyY+n2re/eJoKDXdJXdrylQ MXyzDuX/efqIc/r6fE4prtdbJimsOtWBwDtRltNyluMmpjB+qfU+2powh3ZMVs2jTcVC SjmQ== X-Gm-Message-State: ALoCoQl5XblMZ28WLFlmUqTFzN7svjJ2QSlBx6OLcNNVJ/+do02jULrvRwjmoI8PkbqtjpTIgucSKTQQaKtr12mdq2GcGGZrQFCO2mFks/zcvKxvSl2tPje65iRml4khGqMjsJNQAH6nWdObmaLuC4pDa20gUsSaU5KrRU/uK2aI2ovvN3ZLdPOcYh4HuNuSlEj6M0ld72cKdRaB7woB+4FDff/BcaMLyg== X-Received: by 10.180.76.232 with SMTP id n8mr21657636wiw.72.1441037977374; Mon, 31 Aug 2015 09:19:37 -0700 (PDT) Received: from [10.137.2.12] (ip-78-45-136-74.net.upcbroadband.cz. [78.45.136.74]) by smtp.gmail.com with ESMTPSA id c3sm22957629wja.3.2015.08.31.09.19.36 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Aug 2015 09:19:36 -0700 (PDT) Message-ID: <55E47E97.1090202@2ndquadrant.com> Date: Mon, 31 Aug 2015 18:19:35 +0200 From: Tomas Vondra User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Query > =?windows-1252?Q?1000=D7_slowdown_afte?= =?windows-1252?Q?r_adding_datetime_comparison?= References: <1441037351126-5864045.post@n5.nabble.com> In-Reply-To: <1441037351126-5864045.post@n5.nabble.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org On 08/31/2015 06:09 PM, twoflower wrote: > I have the following three tables: ... > This is the query plan: > > > > If I remove the WHERE condition, it returns immediately. > > Am I doing something obviously wrong? Please share explain plans for both the slow and the fast query. That makes it easier to spot the difference, and possibly identify the cause. Also, what PostgreSQL version is this, and what are "basic" config parameters (shared buffers, work mem)? regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance