groupdate.sql
Languages and libraries
sql function library
SHOW HN2013
How HN took it
2 positive, 3 neutral or asking, 1 mixed, 5 critical, out of 11 comments about the project. Thread score -0.18.
Design: 0 for, 2 againstPrivacy: 0 for, 2 againstPerformance: 0 for, 1 againstIdea: 1 for, 0 against
The thread, comment by comment
Each row is a top-level comment and its replies, in HN's order. Select a cell to open that comment on HN.
positive neutral or mixed critical about another commenter or something else the maker
What HN said
What people liked
Useful and simple wrapper
From 2 comments
Pretty cool! I can see this being really useful. Beware, however, that, while there are certain cases that mysql can utilize indexes in a group by clause if values are constant…
pvnick on HNIf you know that you need to be grouping by dates... then it's usually best to store the date fragments in a separate column so you can take advantage of indexes. The project is…
richardv on HN
Support for more database engines wanted
From 2 comments
Very cool. Thank you for sharing! (Now we just need one for Oracle, DB2, and Sybase...)
memset on HNPostgreSQL and MySQL? Where is the Hive version? :)
gtrubetskoy on HN
Objections
Storing logic in the database adds dependency and complexity
From 3 comments
I'm not sure why this is necessary. It's a very light wrapper around existing SQL functions that adds additional dependencies and makes it more difficult for developers who…
pbnjay on HNI'm sure I'm a neophyte at this, but can someone explain to me why we would want to store functions in a database? It fragments the logic, adds another layer of complexity when…
lowglow on HNIf you know that you need to be grouping by dates... then it's usually best to store the date fragments in a separate column so you can take advantage of indexes. The project is…
richardv on HN
Functions prevent index use, so the approach is slow on large tables
From 2 comments
Pretty cool! I can see this being really useful. Beware, however, that, while there are certain cases that mysql can utilize indexes in a group by clause if values are constant…
pvnick on HNPostgres can use indexes with these functions. If the functions are marked stable or immutable, then the function bodies will be inlined directly into the query.
joevandyk on HN
Piping curl to a root shell is a security concern
From 3 comments
Looks simple and useful. Only worry is that the installation instruction is a curl request piped to mysql with root user... Thanks for sharing!
Rygu on HNdid you access that url with curl to make sure it does no user agent sniffing? how do you know the script is the same on subsequent requests?
hnha on HNIt's an https request to GitHub, which has about a million more subtle ways to own your machine if they really wanted to. Figuring out how to solve the TOCTOU problem for a small…
bcoates on HN
Requests
Support for Oracle, DB2, Sybase and other databases
From 1 comment
Very cool. Thank you for sharing! (Now we just need one for Oracle, DB2, and Sybase...)
memset on HN
Support for Hive
From 1 comment
PostgreSQL and MySQL? Where is the Hive version? :)
gtrubetskoy on HN
Five-minute interval grouping
From 2 comments
A common grouping needed by sysadmins is to group by 5 minute intervals. That query may be more likely to trip up a junior DBA than most of these. Could be useful to add. Example…
Terretta on HNGood suggestion!
akane on HN
Mark PostgreSQL functions IMMUTABLE or STABLE
From 2 comments
The postgres functions should be marked IMMUTABLE. http://www.postgresql.org/docs/9.2/static/xfunc-volatility.html This allows the planner to optimize queries that use the…
joevandyk on HNAwesome, added this to the todo list.
akane on HN
Questions
Why store functions in the database at all?
From 1 comment
I'm sure I'm a neophyte at this, but can someone explain to me why we would want to store functions in a database? It fragments the logic, adds another layer of complexity when…
lowglow on HN
Can PostgreSQL use indexes with these functions?
From 2 comments
You don't need that if you use postgresql: ``` create index foo1 on t1 (date(timestamp)) create index foo2 on t2 (extract(week from timestamp)) ``` Postgres can use almost any…
bjourne on HNPostgres can use indexes with these functions. If the functions are marked stable or immutable, then the function bodies will be inlined directly into the query.
joevandyk on HN
Alternatives named
Precomputed date columns or indexes on expressions
From 2 comments
If you know that you need to be grouping by dates... then it's usually best to store the date fragments in a separate column so you can take advantage of indexes. The project is…
richardv on HNYou don't need that if you use postgresql: ``` create index foo1 on t1 (date(timestamp)) create index foo2 on t2 (extract(week from timestamp)) ``` Postgres can use almost any…
bjourne on HN
Calendar/date dimension table as used in data warehouses
From 2 comments
A common alternative to this for data warehouses and reporting platforms is to construct a date table in advance, with every date enumerated from, say, 1990 through 2050. Every…
chaz on HNThis is the approach recommended by Ralph Kimball for data warehouses. I haven't tried it for OLTP systems. I'd be more inclined to go with ad hoc functional indexes (as…
pjungwir on HN
Store everything in UTC and convert in queries
From 1 comment
Simply use and store everything in UTC. If you ever need to do grouping by time in any other timezone, it would be trivial to do the conversion. DAYOFYEAR(…
tudborg on HN