Skip to content

Instantly share code, notes, and snippets.

View a-mckinley's full-sized avatar

Alastair McKinley a-mckinley

  • Analytics Engines
  • Belfast, United Kingdom
View GitHub Profile
@a-mckinley
a-mckinley / ok.sql
Created March 3, 2020 20:15
Testing table with partial indexes, uses index scan in all rls cases
-- Alastair McKinley 2020
begin;
create table testing as
select value,
type_id,
created,
case when row_number() over (partition by type_id,value order by created desc ) = 1
then true
@a-mckinley
a-mckinley / not-ok.sql
Last active March 3, 2020 20:16
Testing table with jsonb partial indexes, does not choose an index scan in all rls cases
-- Alastair McKinley 2020
begin;
create table testing as
select jsonb_build_object('value',value) as data,
type_id,
created,
case when row_number() over (partition by type_id,value order by created desc ) = 1
then true
@a-mckinley
a-mckinley / .block
Last active October 23, 2019 00:10
Vega-Lite Bl.ocks example
license: bsd-3-clause
border: no
scrolling: no
height: 500
drop table if exists record;
drop table if exists record_type;
create extension if not exists pgcrypto;
-- attributes of each record type including a parameter used in the indexes
create table record_type (
id bigint not null primary key,
index_n_chars integer not null,
name text unique
);
@a-mckinley
a-mckinley / .block
Created August 31, 2018 10:01
fresh block
license: mit