Small improvement to tlist_matches_tupdesc()

From: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Small improvement to tlist_matches_tupdesc()
Date: 2015-10-29 03:16:28
Message-ID: CAKJS1f9+WAWONZNGeCujvTyZyTnDvSg+5Rd2J66PfgSQqa0v4Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I just found myself in execScan.c. I noticed that tlist_matches_tupdesc()
is a bit wasteful in some cases as it goes to the trouble of matching the
tlist to the TupleDesc item by item until it runs out of tlist items
or finds a non-match. Once the loop completes it ensures that all tlist
items were consumed, so basically in other words, it checks the lengths
match.

I think likely this was just not made optimal originally in d0b4399 when
the length property etc were added to List

The attached patch adds a fast path so that no list items are compared if
the lengths don't match.

Is this worth fixing?

--
David Rowley http://www.2ndQuadrant.com/
<http://www.2ndquadrant.com/>
PostgreSQL Development, 24x7 Support, Training & Services

Attachment Content-Type Size
tlist_matches_tupdesc_fastpath.patch application/octet-stream 1.5 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2015-10-29 03:27:49 Re: Small improvement to tlist_matches_tupdesc()
Previous Message Noah Misch 2015-10-29 02:51:37 Re: pg_dump