Skip to content

Instantly share code, notes, and snippets.

@umitanuki
Created May 1, 2011 21:02
Show Gist options
  • Save umitanuki/950872 to your computer and use it in GitHub Desktop.
Save umitanuki/950872 to your computer and use it in GitHub Desktop.
Join fix issue
create table size_m as select i as id, repeat(i::text, i % 100) as val from generate_series(1, 20000) i;
create table size_l as select i as id, m.id as m_id, repeat(i::text, i % 100) as val from generate_series(1, 1000000) i, size_m m where i.i / 10 = m.id;
--create index idx_m_id on size_l (m_id);
analyze size_m;
analyze size_l;
----
select m_id, sum_len from size_m m inner join(select m_id, sum(length(val)) as sum_len from size_l group by m_id)l on m.id = l.m_id where val = '10101';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment