Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id DEAD0475AB1 for ; Tue, 30 Apr 2002 16:04:33 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id E608A475928 for ; Tue, 30 Apr 2002 16:04:32 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.4/8.11.4) with ESMTP id g3UK4XF21993 for ; Tue, 30 Apr 2002 16:04:34 -0400 (EDT) To: pgsql-bugs@postgresql.org Subject: Re: Bug #652: NAMEDATALEN limitations In-reply-to: <21413.1020192353@sss.pgh.pa.us> References: <20020430181519.5E5D9475985@postgresql.org> <21326.1020191577@sss.pgh.pa.us> <21413.1020192353@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Tue, 30 Apr 2002 14:45:53 -0400" Date: Tue, 30 Apr 2002 16:04:33 -0400 Message-ID: <21990.1020197073@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200204/187 X-Sequence-Number: 3607 I said: > One possible theory is that if NAMEDATALEN isn't a multiple of > sizeof(int), the compiler's idea of sizeof(NameData) will probably be > NAMEDATALEN rounded up to the next multiple of sizeof(int). For the record, this does indeed seem to be the root cause for Erik's complaint. relcache.c declares the key size for its relation name cache index as sizeof(NameData) --- so if that's larger than NAMEDATALEN the hashtable code will end up trying to compare pad bytes that probably haven't been zeroed out. It looks to me like it would not really be practical to expect the system to work when sizeof(NameData) is different from NAMEDATALEN; we could maybe eliminate the existing discrepancies but more would surely creep in. So I've added comments to document that NAMEDATALEN must be a multiple of sizeof(int). BTW, I suspect that Names used as hashtable keys may explain the residual speed differences that people have been reporting for large values of NAMEDATALEN. The dynahash.c code assumes fixed-length keys and will compare all bytes out to the specified length, no matter what --- so the extra cycles may all be spent in key comparisons for dynahash tables. Perhaps this could be fixed. regards, tom lane