By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
Help with an interesting Postgres question: Why isn't an Index Only Scan used on a partition accessed via the parent table?.
create table versions (v1 text, v2 text);
insert into versions values
('1.2', '1.3'),
('2.2', '2.1'),
('1.2.3', '1.2.4'),
('1.10', '1.2');
CREATE TABLE
INSERT 0 4
SELECT string_to_array(v1, '.')::int[] AS v1
, string_to_array(v2, '.')::int[] AS v2
,(string_to_array(v1, '.')::int[] > string_to_array(v2, '.')::int[])::text AS cmp
FROM versions;
v1 | v2 | cmp |
---|---|---|
{1,2} | {1,3} | false |
{2,2} | {2,1} | true |
{1,2,3} | {1,2,4} | false |
{1,10} | {1,2} | true |
SELECT 4