public inbox for [email protected]  
help / color / mirror / Atom feed
From: Ron Johnson <[email protected]>
To: pgsql-generallists.postgresql.org <[email protected]>
Subject: Re: A way to optimize sql about the last temporary-related row
Date: Thu, 27 Jun 2024 11:27:40 -0400
Message-ID: <CANzqJaA1omaViNqAdEQzfKng8D4X6=Fku_spJhJNEvDt9Nt99Q@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>

On Thu, Jun 27, 2024 at 11:20 AM [email protected] <[email protected]>
wrote:
[snip]

> -- insert 4M records
> insert into test_table(pk_id) select generate_series(1,4000000,1);
>
> -- now set some random data, distribuited between specific ranges (as in
> my production table)
> update test_table set
> datetime_field_1 = timestamp '2000-01-01 00:00:00' + random() *
> (timestamp '2024-05-31 23:59:59' - timestamp '2000-01-01 00:00:00'),
> integer_field_1 = floor(random() * (6-1+1) + 1)::int,
> integer_field_2 = floor(random() * (200000-1+1) + 1)::int;
>
>
> -- indexes
> CREATE INDEX idx_test_table_integer_field_1 ON test_table(integer_field_1);
> CREATE INDEX xtest_table_datetime_field_1 ON test_table(datetime_field_1
> desc);
> CREATE INDEX idx_test_table_integer_field_2 ON test_table(integer_field_2);
>
>
Off-topic: save some resources by vacuuming before creating indices.


view thread (3+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: A way to optimize sql about the last temporary-related row
  In-Reply-To: <CANzqJaA1omaViNqAdEQzfKng8D4X6=Fku_spJhJNEvDt9Nt99Q@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox