RE: Clean up shop database

From: Richard Klingler <richard(at)klingler(dot)net>
To: pgsql-sql(at)lists(dot)postgresql(dot)org
Subject: RE: Clean up shop database
Date: 2022-01-19 13:59:52
Message-ID: 20220119145952950059.4dd93ada@klingler.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, 19 Jan 2022 05:51:56 -0800, Mike Sofen wrote:
>> From: Richard Klingler <richard(at)klingler(dot)net> 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.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Rob Sargent 2022-01-19 16:41:29 Re: Clean up shop database
Previous Message Richard Klingler 2022-01-19 13:57:38 Re: Clean up shop database