kine icon indicating copy to clipboard operation
kine copied to clipboard

can we implement the watch by trigger for PostgresDB?

Open LuMerkle opened this issue 5 years ago • 2 comments

Hi, Very glad to see kine now support postgresql! By reading the code, if I am correct, it is still implementing watch by selecting the table. Since postgresDB can support trigger, my question is that is it possible to define a trigger on the kine table, so that any insert/update/delete can trigger an action/event so we don't have to do the query all the time. Are there any disadvantage of this approach? Thank you.

LuMerkle avatar Dec 26 '19 08:12 LuMerkle

Actually I mean trigger + pg_notify + listen on the go side (https://github.com/go-pg/pg)

LuMerkle avatar Dec 27 '19 01:12 LuMerkle

The polling is a lot more efficient than you would think. On average there is no delay but in the worst case scenario you get about a 500ms delay in a watch. Right now the bigger problem with postgres is that the queries/schema are not optimize so it doesn't perform well at all compared to MySQL. You quickly get CPU bound in postgres where as the mysql implementation chugs along pretty idle.

ibuildthecloud avatar Jan 29 '20 16:01 ibuildthecloud