Open yugabyte-ci opened 2 weeks ago
DDL for the table:
CREATE TABLE IF NOT EXISTS outbox (
bucket_message_key smallint NOT NULL,
id UUID,
account_identifier TEXT,
span_identifier TEXT,
topic varchar(249),
message_key TEXT,
payload BYTEA,
encryption_metadata TEXT,
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY ((bucket_message_key), created_at asc, id asc)
) SPLIT INTO 36 TABLETS;
ALTER TABLE outbox ALTER COLUMN message_key DROP NOT NULL;
CREATE INDEX CONCURRENTLY IF NOT EXISTS outbox_id_idx ON outbox(id);
Reported to pgsql-bugs@lists.postgresql.org: https://www.postgresql.org/message-id/CACfbPhMXe2f81nKgX9PC0q3n4jVkHobXcUj-88h27j1zUAb0Lw%40mail.gmail.com
According to the response from Tom Lane, it's more involved that we previously thought:
The trouble with the LEAST/GREATEST formulation is that it may result in different semantics in situations where val1 and val2 aren't the same type. Also, LEAST/GREATEST rely on the default btree opclass for the common type, which might not match the semantics of the comparison operators that the current coding chooses.
There are ways around that --- one could be to transform to LEAST/GREATEST only when the arguments do resolve as the same type. And perhaps you could convince people that BETWEEN ought to depend on the default btree opclass not on operator names. But it's all a lot messier than you might think.
Jira Link: DB-13863
Description
When using
between symmetric
, there is a massive increase in inter-az traffic; the queries and theEXPLAIN
s are below. We could optimise this significantly or at least at a warning to the docs highlighting the increased traffic, as increased traffic in most cloud environments will result in more costs.Queries
Slow and significant cross-AZ traffic:
select FROM outbox_events WHERE bucket_message_key = 0 and created_at between SYMMETRIC '2023-11-16 17:00:00' and '2023-11-16 18:00:00';
Our tests seem on par (if not better than >= and <), at least in our test environment.
select FROM outbox_events WHERE bucket_message_key = 0 and created_at between '2023-11-16 17:00:00' and '2023-11-16 18:00:00';
Our tests seem on par (if not better than >= and <), at least in our test environment.
select FROM outbox_events WHERE bucket_message_key = 0 and created_at >= '2023-11-16 17:00:00' and created_at < '2023-11-16 18:00:00';
Outputs of EXPLAINs