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 1nABVH-0007pC-Cu for pgsql-sql@arkaria.postgresql.org; Wed, 19 Jan 2022 13:59:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nABVG-0003Tj-9V for pgsql-sql@arkaria.postgresql.org; Wed, 19 Jan 2022 13:59:58 +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 1nABVG-0003TU-1B for pgsql-sql@lists.postgresql.org; Wed, 19 Jan 2022 13:59:58 +0000 Received: from mail.klingler.net ([5.189.138.105]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nABVD-0005SH-OY for pgsql-sql@lists.postgresql.org; Wed, 19 Jan 2022 13:59:57 +0000 Date: Wed, 19 Jan 2022 14:59:52 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=klingler.net; s=2020; t=1642600793; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VXr+C37CKNE95w8DG9T/ozeIlH5vSsu/I4fRYu0dk3E=; b=0eofTIZgdLnaymyMc1bFs3Z/hZFviEBo7Cj/pA48x2olrY0mK1TVG+YcehhIhKG0yFLzxL j1/dIzS+nbZm90hzsXxiYQGpFhKHaP6wg2mdr9LNTNJAEAr0qgf+lkpKm07BicGbvKdQtq Rf+wrBSZBJZZg5jPh4Q7ao5Qm6HZ+rg= From: Richard Klingler To: pgsql-sql@lists.postgresql.org Message-ID: <20220119145952950059.4dd93ada@klingler.net> In-Reply-To: <122401d80d3b$ba859da0$2f90d8e0$@runbox.com> References: <20220119141711201637.c796844d@klingler.net> <20220119143718285650.48772b27@klingler.net> <122401d80d3b$ba859da0$2f90d8e0$@runbox.com> Subject: RE: Clean up shop database MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Authentication-Results: ORIGINATING; auth=pass smtp.auth=richard@klingler.net smtp.mailfrom=richard@klingler.net List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, 19 Jan 2022 05:51:56 -0800, Mike Sofen wrote: >> From: Richard Klingler Sent: Wednesday, January > 19, 2022 5:37 AM >> On Wed, 19 Jan 2022 06:32:19 -0700, Rob Sargent wrote: >>> >>>> No it does not...but I assume it lists products that where at least >>>> ordered before January 1st 2021 as it contains lower product IDs. >>>> >>>> Hmm..gives me: >>>> >>>>> ERROR: function max(boolean) does not exist >>>> LINE 5: having max(o.orderdate < '2021-01-01') >>>> >>>> >>> Sorry >>>> >>>> max(o.orderdate )< '2021-01-01' >>> >>>> > >> You're a genius :-) > >> Looks perfect... > > There is one caveat here: unless you are 100% certain that the > product.pieces count is 100% accurate, you should sum the > orderitems.productid. It is pretty common for the indirect counts (like > product.pieces) to get out of sync with the "normal" source of truth (line > items). > > This does depend on design of your system, of course. > > Mike > Well I use the productid for rough checking so that they are created some time before the specified date. And I won't delete any records..just mark them as inactive... that way datatables loads much faster when it just grabs the active products via ajax call.