Skip site navigation (1) Skip section navigation (2)

equal() perf tweak

From: Neil Conway <neilc(at)samurai(dot)com>
To: PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: equal() perf tweak
Date: 2003-11-03 14:00:34
Message-ID: 1067868034.3089.225.camel@tokyo (view raw, whole thread or download thread mbox)
Lists: pgsql-hackerspgsql-patches
Currently, equal() does the following for List nodes:

case T_List:
	List	   *la = (List *) a;
	List	   *lb = (List *) b;
	List	   *l;

	 * Try to reject by length check before we grovel through
	 * all the elements...
	if (length(la) != length(lb))
		return false;
	foreach(l, la)
		if (!equal(lfirst(l), lfirst(lb)))
			return false;
		lb = lnext(lb);
	retval = true;

This code is inefficient, however: length() requires iterating through
the entire list, so this code scans both lists twice. The attached patch
improves this by implementing equal() with a single scan of both lists.


Attachment: equal-list-perf-1.patch
Description: text/x-patch (1.3 KB)


pgsql-hackers by date

Next:From: Andrew SullivanDate: 2003-11-03 14:16:37
Subject: Re: adding support for posix_fadvise()
Previous:From: Neil ConwayDate: 2003-11-03 13:50:00
Subject: Re: adding support for posix_fadvise()

pgsql-patches by date

Next:From: Tom LaneDate: 2003-11-03 15:00:25
Subject: Re: bufmgr code cleanup
Previous:From: Jan WieckDate: 2003-11-03 13:31:55
Subject: Re: bufmgr code cleanup

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group