If timing is one dimension of your data and you want to index a timestamptz column. How do you index it? What solution is the best for your case?

Suppose that you have table_a, which has a timestamptz column named column_tz. Possibly, column_tz has numerous values of timestamp. By any reason you need to index column_tz by date because you don’t want to build a huge B-tree with many nodes in your memory unnecessarily. Unfortunately you will recognize that you can not create the index like this

CREATE INDEX index_table_a_column_tz_by_date ON table_a (column_tz::DATE);

Can magic parentheses help in this case?

Tung Nguyen

A coding lover. Mouse and keyboard are my friends all day long. Computer is a part of my life and coding is my cup of tea.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store