Skip to main content
Question

Does it make sense to encode a Date Column in RLE?

  • December 17, 2019
  • 2 replies
  • 13 views

chaima
Forum|alt.badge.img+2
  • Participating Frequently

Hi team,
A customer is wondering how to encode a low cardinality column of data type Date.
Does it make sense to encode it as RLE?
Thanks,

Chaima

2 replies

Jim_Knicely
Forum|alt.badge.img+2
  • Participating Frequently
  • December 17, 2019

Sure! Note that internally Vertica stores dates an an integer. And Database Designer will recommend RLE for a DATE when appropriate!

Example:

dbadmin=> SELECT a_date, COUNT(*) FROM date_rle GROUP BY a_date ORDER BY a_date;
   a_date   | COUNT
------------+--------
 2019-12-17 | 525307
 2019-12-18 | 837955
 2019-12-19 | 839409
 2019-12-20 | 838552
 2019-12-21 | 839488
 2019-12-22 | 838677
 2019-12-23 | 839014
 2019-12-24 | 838537
 2019-12-25 | 838452
 2019-12-26 | 838687
 2019-12-27 | 314530
(11 rows)

dbadmin=> SELECT projection_column_name, encoding_type FROM projection_columns WHERE table_name = 'date_rle' LIMIT 1;
 projection_column_name | encoding_type
------------------------+---------------
 a_date                 | AUTO
(1 row)

dbadmin=> SELECT designer_design_projection_encodings('date_rle', '/home/dbadmin/date_rle.sql', TRUE, TRUE);
 designer_design_projection_encodings
--------------------------------------

(1 row)

dbadmin=> SELECT projection_column_name, encoding_type FROM projection_columns WHERE table_name = 'date_rle' LIMIT 1;
 projection_column_name | encoding_type
------------------------+---------------
 a_date                 | RLE
(1 row)

chaima
Forum|alt.badge.img+2
  • Author
  • Participating Frequently
  • December 17, 2019

Thanks Jim for the quick answer!