how to check if given update is from trigger or why i hate orms?

  • we use orm
  • yes, and?
  • and we have a problem with it…
  • you already said that

now, imagine a simple scenario:

  • objects table (let's name it “topics"), which contains column: posts_count
  • sub-objects table (posts), with foreign key to topics
  • triggers which update posts_count on insert/update/delete on posts

simple? yes? well. it was. now, enter disaster: orm.

Continue reading how to check if given update is from trigger or why i hate orms?

ed2k checksumming

i needed a way to generate ed2k urls based on existing files on my harddrive.

ed2k link looks like this:

ed2k://|file|FILENAME|FILESIZE|CHECKSUM|/

filename and filesize are of course known, but what about checksum? i tried to find some ready program to calculate them, but failed. it might be because i spent something like 3 minutes on it, but anyway – i didn't find it. so i tried to find algorithm description.

luckily there is a nice algorithms description. algorithms, as there apparently are two separate algorithms, not fully compatible with each other.

based on the information i was able to write a short perl script which does the job:

=> cat ed2ksum.pl
#!/usr/bin/perl -l
use Digest::MD4 qw(md4 md4_hex);open$f,pop or die$!;$c.=md4$b while sysread$f,$b,9728000;print uc md4_hex$c

yes, it is unreadable. but it works. first version was longer (about 15 lines), but then i decided to try to make it shorter. and shorter. and then even shorter. most probably it is not the shortest possible way, but i'm safisfied with it.

how does it work? simply:

=> ./ed2ksum.pl Slony-I-concept.pdf
E8715CD212CD75E0EE4B6C526D5BF36A

hope you'll find it useful.

how many 1sts of any month were sundays – since 1901-01-01?

nixternal wrote about boost library for c++.

with it he was able to find the answer to title question in miliseconds (he didn't specify how many, but let's assume that is was less than 10 ms).

so i decided to check how fast can i do it in postgresql …

Continue reading how many 1sts of any month were sundays – since 1901-01-01?

shared buffers and their impact on performance

just lately we found interesting case about shared_buffers settings.

the database in question is rather simple:

  • 3 tables
  • a bit over 60 gigabytes
  • around 150 million rows

the server we run it on is not really fancy:

  • 2, single core, 3ghz xeons
  • 16 gb of ram
  • 6x 72gb, scsi, 15krpm discs in low-end hardware raid 10.

Continue reading shared buffers and their impact on performance

overprotective developers

i'm recently under impression that pg developers are overprotective. who do they protect?

us, users.

i mean – don't get me wrong – i live with, and (to some extent) thanks to the piece of marvelous technology which is postgresql ordbms.

i use it, i try to help other use it. i don't think there is any better database available now (at the very least – for my purposes).

but, just lately, i some to see some cases where decissions are made in a way to “protect us (dbas) from our faults".

Continue reading overprotective developers