Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select *
- from description
- where
- term ilike %% 'query'
- order by
- term ilike 'query' -- prefer exact match
- term ilike 'query' -- prefer starts with
- -- term %% 'query' -- fill with fuzzy trigram match
- limit 10
- -- select * FROM (
- select * -- 100 ms when run alone
- FROM description d
- where term ilike 'hyp'
- UNION
- select * from ( -- 100 ms when run alone, returns 1000 rows if no limit
- select *
- FROM snomed_ct.description d
- where d.term ilike 'hyp%'
- ) as x
- UNION
- select * -- 200ms seconds when run alone (with limit 10)
- FROM description d
- where d.term % 'hyp'
- -- ) as d
- limit 10
- select *
- FROM description d
- where d.term % 'hyp'
- selects = [select1_iterator, select2_iterator, select3_iterator, ]
- iter = chain(selects) # pick from 1st iterator, then second, then 3rd
- iter = duplicated(selects) # skip duplicates
- iter = limit(selects, 10) # pick 1st 10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement