Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. select version();
  2. version
  3. ---------------------------------------------------------------------------------------------------------
  4. PostgreSQL 11.1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28), 64-bit
  5. (1 row)
  6.  
  7.  
  8. drop table if exists tab1;
  9. DROP TABLE
  10. create table tab1 ( r_object_id char(16) primary key, dcmi_title varchar(250) );
  11. CREATE TABLE
  12. create index tab1__dcmi_title on tab1 ( lower(dcmi_title) );
  13. CREATE INDEX
  14. create or replace function custom_lower(s text) RETURNS text as $$
  15. SELECT LOWER(s);
  16. $$ LANGUAGE sql;
  17. CREATE FUNCTION
  18. drop table if exists tab2;
  19. DROP TABLE
  20. create table tab2 ( r_object_id char(16) primary key, dcmi_title varchar(250) );
  21. CREATE TABLE
  22. create index tab2__dcmi_title on tab2 ( custom_lower(dcmi_title) );
  23. CREATE INDEX
  24. explain SELECT * FROM ( SELECT r_object_id, lower(dcmi_title) s_dcmi_title from tab1 ) t WHERE s_dcmi_title = 'all aboard 1 poster pack'
  25. ;
  26. QUERY PLAN
  27. -------------------------------------------------------------------------------
  28. Index Scan using tab1__dcmi_title on tab1 (cost=0.14..8.16 rows=1 width=100)
  29. Index Cond: (lower((dcmi_title)::text) = 'all aboard 1 poster pack'::text)
  30. (2 rows)
  31.  
  32.  
  33. explain SELECT * FROM ( SELECT r_object_id, lower(dcmi_title) calculated_col from tab1 WHERE lower(dcmi_title) = 'all aboard 1 poster pack' ) t
  34. ;
  35. QUERY PLAN
  36. -------------------------------------------------------------------------------
  37. Index Scan using tab1__dcmi_title on tab1 (cost=0.14..8.16 rows=1 width=100)
  38. Index Cond: (lower((dcmi_title)::text) = 'all aboard 1 poster pack'::text)
  39. (2 rows)
  40.  
  41.  
  42. explain SELECT * FROM ( SELECT r_object_id, custom_lower(dcmi_title) calculated_col from tab2 WHERE custom_lower(dcmi_title) = 'all aboard 1 poster pack' ) t
  43. ;
  44. QUERY PLAN
  45. -------------------------------------------------------------------------------
  46. Index Scan using tab2__dcmi_title on tab2 (cost=0.14..8.16 rows=1 width=100)
  47. Index Cond: (lower((dcmi_title)::text) = 'all aboard 1 poster pack'::text)
  48. (2 rows)
  49.  
  50.  
  51. explain SELECT * FROM ( SELECT r_object_id, custom_lower(dcmi_title) s_dcmi_title from tab2 ) t WHERE s_dcmi_title = 'all aboard 1 poster pack'
  52. ;
  53. QUERY PLAN
  54. ---------------------------------------------------------------
  55. Subquery Scan on t (cost=0.00..13.25 rows=1 width=100)
  56. Filter: (t.s_dcmi_title = 'all aboard 1 poster pack'::text)
  57. -> Seq Scan on tab2 (cost=0.00..11.62 rows=130 width=100)
  58. (3 rows)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement