Re: [GENERAL] Optimizing query: select ... where id = 4 and md5(...) = '...'

2006-07-03 Thread Alexander Farber
Hi Alban, On 7/3/06, Alban Hertroys <[EMAIL PROTECTED]> wrote: Alexander Farber wrote: > punbb=> select username, md5('deadbeef' || password) from users where id > = 4; > username | md5 > --+-- > Vasja| dcde745cc304742e26d62e683a9ecb0a >

Re: [GENERAL] Optimizing query: select ... where id = 4 and md5(...)

2006-07-03 Thread Alban Hertroys
Alexander Farber wrote: I wonder, what is faster: fetching 2 columns - the username and the md5-result and then comparing the md5 string against the argument in my app, like here: punbb=> select username, md5('deadbeef' || password) from users where id = 4; username | md5 ---

Re: [GENERAL] Optimizing query: select ... where id = 4 and md5(...) = '...'

2006-07-03 Thread Alexander Farber
Yes, you're probably right. I'm just trying to ensure, that the slow md5() function isn't called for every row in the table. If that's not the case, then the other tiny speed differences are not that important for me. Your query works too, thanks for the hint. punbb=> select username, md5('dead

Re: [GENERAL] Optimizing query: select ... where id = 4 and md5(...) = '...'

2006-07-03 Thread Martijn van Oosterhout
On Mon, Jul 03, 2006 at 03:13:15PM +0200, Alexander Farber wrote: > Hello, > > in my application I'm trying to authenticate users > against a table called "users". The integer column > "id" should match, but also an md5 hash of the > "password" column (salted with a string) should match. > My auth

[GENERAL] Optimizing query: select ... where id = 4 and md5(...) = '...'

2006-07-03 Thread Alexander Farber
Hello, in my application I'm trying to authenticate users against a table called "users". The integer column "id" should match, but also an md5 hash of the "password" column (salted with a string) should match. My authentication function (written in C, using libpq) should return a "username" (is