HackerTrans
TopNewTrendsCommentsPastAskShowJobs

castorp

no profile record

comments

castorp
·3 ปีที่แล้ว·discuss
> I suspect that's a pretty non-standard/rarely-used feature though. If you learn SQL you likely won't encounter this

Recursive common table expressions are part of the SQL standard (since 1999) and are quite frequently used to traverse hierarchical data (aka "adjacency list").

It is part of basically all (good) SQL tutorials - at least in the "advanced" part.
castorp
·4 ปีที่แล้ว·discuss
> PostgreSQL has built in support for UUIDv4 through the pgcrypto or the uuid-ossp extensions.

Since Postgres 13 installing an extension is no longer necessary as gen_random_uuid() is part of the core.
castorp
·4 ปีที่แล้ว·discuss
Yes, it matters.

Many Postgres features aren't supported on Redshift (set returning functions, indexes, ...) and many tools that work just fine with Postgres error out because Redshift does things differently or doesn't support features that Postgres does.
castorp
·4 ปีที่แล้ว·discuss
> rather than Redshift

Despite what the Amazon marketing is telling, Redshift is not really a "fork" of Postgres.

To my knowledge they only used the SQL parser and the wire protocol from Postgres.

The optimizer, query executor and storage engine are totally different. The whole "Redshift is Postgres" is complete marketing BS in my opinion.
castorp
·4 ปีที่แล้ว·discuss
You need to use pg_dump from the new version, not from the old version.
castorp
·4 ปีที่แล้ว·discuss
> It sounds like Russia might get declared a terrorist state soon.

Lithuania has apparently already done that.
castorp
·4 ปีที่แล้ว·discuss
I have been working with Oracle for more than 20 years now. I think I only had very few situations where an "index organized table" (=clustered index) was useful or actually provided a major performance benefit over a "heap table". So I never really miss them in Postgres.
castorp
·5 ปีที่แล้ว·discuss
> Without dura, you use Ctrl-Z in your editor to get back to a good state.

I just turn on "Local History" in my NetBeans IDE which creates a new version of the file each time I save it. No need to use Ctrl-Z for that.
castorp
·5 ปีที่แล้ว·discuss
You don't have to do that "manually". Postgres supports the conversion using the `at time zone` operator.
castorp
·5 ปีที่แล้ว·discuss
Did you try Qwant? https://www.qwant.com/maps
castorp
·5 ปีที่แล้ว·discuss


    select extract(month from justify_interval(timestamp '2022-01-01' - timestamp '2021-11-01'))
returns 2
castorp
·5 ปีที่แล้ว·discuss
Well for "counting buckets" you can use `date_bin()` since Postgres 14 which groups the difference between timestamps into defined intervals.
castorp
·5 ปีที่แล้ว·discuss
But the difference between 2021-01-01 and 2020-12-31 is only one day, not a year.

It gets even strange for e.g. select DATEDIFF(year, '2021-12-01', '2022-01-01') which still returns 1 even though that's a whole month. I don't see a use case for this kind of result
castorp
·5 ปีที่แล้ว·discuss
> For example, find all users who have have been active at least 10 days.

Well, then you only need to compare the difference of the timestamp (or date) values with an interval of 10 days. e.g. end_time - start_time >= interval '10 days'
castorp
·5 ปีที่แล้ว·discuss
> No, for example, the datediff in years for New Year's Eve and New Year's Day should be 1

I don't understand the purpose of such a calculation. If you want to check if two dates (or timestamps) fall into the same year, you compare the year part of them. If you want to check how far they are apart, you compare the difference between the two to an interval.
castorp
·5 ปีที่แล้ว·discuss
The question is: what do you do with the result?

If you e.g. want to check if two timestamps are more than a year apart you just compare the difference to an interval of 1 year.
castorp
·5 ปีที่แล้ว·discuss
The "distance" between two dates seems quite useful. In Postgres there is no need for a datediff() function - you would just subtract the two dates: date '2021-01-01' - date '2020-12-31'
castorp
·5 ปีที่แล้ว·discuss
I never understood the need for a datediff function. In Postgres (or Oracle) you just subtract two timestamps and use the resulting interval. It's a different approach to the same problem.
castorp
·5 ปีที่แล้ว·discuss
"hundreds" of concurrent connections isn't really a problem for Postgres.

Several thousands are - at least up until now. V14 will improve this substantially.