Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1om5ca-0000Vi-3W for pgsql-general@arkaria.postgresql.org; Sat, 22 Oct 2022 03:56:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1om5cX-0003sw-Vm for pgsql-general@arkaria.postgresql.org; Sat, 22 Oct 2022 03:56:25 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1om5cX-0003sm-KF for pgsql-general@lists.postgresql.org; Sat, 22 Oct 2022 03:56:25 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1om5cV-0001fE-3t for pgsql-general@postgresql.org; Sat, 22 Oct 2022 03:56:24 +0000 Received: by mail-wm1-x335.google.com with SMTP id c3-20020a1c3503000000b003bd21e3dd7aso6443445wma.1 for ; Fri, 21 Oct 2022 20:56:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=Q95XBXxkzCyh8qnwN8+4n1NjMwBp4GKtAFQuxfDNDmg=; b=yVPml4eSRYmEwv8iIdpIlJeDr532fFtaxZ585iuDqJ5eAO3xKbTpmPG8dHak++K11I 5UpcpCfpUx/2FPgjB0MT17jkF096uIyLSl8TNmXYNk9U25ThOaZPe8+hqem8RFbc57TO jESgKrLPbM4P0jRS2PM64ENeSFENO6WLN/LrZCTjTDiOzpGGZ1utQTSAabccjPcai/u+ QGnH9n2a2H5JvOhbWy/LX3u1aMmY5au4Fc+RfX0hcHDRuoHDvdjel4nMd1Md2CZJtmG+ 0edtLaPr0E3Gd6mnghQRBiUnRuxHoPA/SO27IkbWi5mmLPsjhqY+cx/Vlq4Xki+PYoUu foaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Q95XBXxkzCyh8qnwN8+4n1NjMwBp4GKtAFQuxfDNDmg=; b=2rak22uu7nDRcr2NjSkqm3q1OnRqJ7k/Dh8xvFw96JT5RBFlBEuCzdLLxjNi7ACSjj OVLMMwLaLHumiD8IA2mRt3BY0PjMmEd0l2dHLWndT3D2ROKgcGpjxl6ZC+mfzUZpeOEl /p7LH9c9bzT4xVmNz4ROFfP/tsWreU8qaR8R0supVZRlojzU2Xm9pYJZRxIom6TWF0y9 E47s0hihmSy9dwopJdiekgOmMhztHTZw8K9DkgLaRVIfEXC1t5nJVCrO0yUheQbB3eKw ApFupFk+u8PXQMHgDPbmoQU+4RACoIZDhD8jI9JbgddSeIIr2S03E6UC9GzIYF08d8jX 5VEQ== X-Gm-Message-State: ACrzQf2/YimYQpsJew9tBSMOKQliwuLB0Jg+OO1aHtFVsNJOUDBslOlE EKv6SPjctBrSinrvUh2Q21g+2A== X-Google-Smtp-Source: AMsMyM4dFaH0uBDgJee06eeAF1ZuDgq05IwC60uToR9nY3nYzgCYmjDHBwvktHXh374Yur7pJN1VAg== X-Received: by 2002:a05:600c:490f:b0:3c6:2c21:97f6 with SMTP id f15-20020a05600c490f00b003c62c2197f6mr35395579wmp.177.1666410980941; Fri, 21 Oct 2022 20:56:20 -0700 (PDT) Received: from localhost.localdomain (178-190-179-115.adsl.highway.telekom.at. [178.190.179.115]) by smtp.gmail.com with ESMTPSA id j28-20020a5d6e5c000000b0022cd27bc8c1sm24744382wrz.9.2022.10.21.20.56.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 20:56:20 -0700 (PDT) Message-ID: <19ee98cd64c022b906d11e690bbff012ef71baff.camel@cybertec.at> Subject: Re: constantly updated table in Amazon RDS From: Laurenz Albe To: Julie Nishimura , "pgsql-general@postgresql.org" Date: Sat, 22 Oct 2022 05:56:20 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-2.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, 2022-10-21 at 18:51 +0000, Julie Nishimura wrote: > A table is constantly updated by inserting new rows. Will it affect select if where clause is based on > date? > Does "where clause" to specify > date and < now? Potentially yes, if the rows you query are the most recent rows, for which PostgreSQL has the least accurate statistics. There is a heuristics in the PostgreSQL optimizer: it looks for the actual maximal value to adjust the last histogram bucket boundary. If that is not enough, you can get PostgreSQL to gather table statistics more often by lowering "autovacuum_analyze_scale_factor" for that table: ALTER TABLE tab SET (autovacuum_analyze_scale_factor = 0.01); You'd have to experiment for the best value. Yours, Laurenz Albe