Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select count(*) -- rp.tag
- from submission
- inner join post rp on submission.id = rp.submission_id
- where user_name = ?1
- and lower(rp.tag) like ('%verified%')
- and not lower(rp.tag) like ('%unverified%');
- select count(*) rp.tag
- from submission
- inner join post rp on submission.id = rp.submission_id
- where user_name = ?1
- and lower(tag) like ('%verified%') and not lower(tag) like ('%unverified%')
- LIMIT 1
- CREATE INDEX subm_userName_tag_idx ON submission (user_name, lower(tag));
- and lower(tag) like ('%verified%') and not lower(tag) like ('%unverified%')
- SELECT count(*) FROM (
- SELECT -- empty SELECT list
- FROM submission
- JOIN ...
- WHERE ...
- LIMIT 1
- ) sub
- SELECT EXISTS (
- SELECT FROM submission s
- JOIN post p ON s.id = rp.submission_id
- WHERE s.user_name = ?
- AND p.tag ~* 'verified'
- AND NOT p.tag ~* 'unverified'
- );
- CREATE INDEX post_tag_gin_trgm_idx ON post USING gin (tag gin_trgm_ops);
- UPDATE foo
- SET bar = 'baz'
- WHERE EXISTS ( ...) -- like above
- AND bar IS DISTINCT FROM 'baz' -- avoid empty updates
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement