Re: Page Scan Mode in Hash Index
От | Ashutosh Sharma |
---|---|
Тема | Re: Page Scan Mode in Hash Index |
Дата | |
Msg-id | CAE9k0PmZJpZW5LFQCj5LAp3STVk9vOUZrnF1XUWcNeP0AfCSbA@mail.gmail.com обсуждение исходный текст |
Ответ на | [HACKERS] Page Scan Mode in Hash Index (Ashutosh Sharma <ashu.coek88@gmail.com>) |
Ответы |
Re: Page Scan Mode in Hash Index
Re: Page Scan Mode in Hash Index Re: Page Scan Mode in Hash Index |
Список | pgsql-hackers |
Hi, > I think you should consider refactoring this so that it doesn't need > to use goto. Maybe move the while (offnum <= maxoff) logic into a > helper function and have it return itemIndex. If itemIndex == 0, you > can call it again. okay, Added a helper function for _hash_readpage(). Please check v4 patch attached with this mail. Notice that the code in the "else" branch of the > if (itemIndex == 0) stuff could actually be removed from the else > block without changing anything, because the "if" block always either > returns or does a goto. That's worthy of a little more work to try to > make things simple and clear. Corrected. > > + * We find the first item(or, if backward scan, the last item) in > > Missing space. > Corrected. > In _hash_dropscanbuf(), the handling of hashso_bucket_buf is now > inconsistent with the handling of hashso_split_bucket_buf, which seems > suspicious. I have corrected it. Suppose we enter this function with so->hashso_bucket_buf > and so->currPos.buf both being valid buffers, but not the same one. > It looks to me as if we'll release the first pin but not the second > one. Yes, that is because we no need to release pin on currPos.buf if it is an overflow page. In page scan mode once we have saved all the qualified tuples from a current page (could be an overflow page) into items array we do release both pin and lock on a overflow page. This was not true earlier, let us assume a case where we are supposed to fetch only fixed number of tuples from a page using cursor and in such a case once the number of tuples to be fetched is completed we simply return with out releasing pin on a page being scanned. If this page is an overflow page then by end of scan we will end up with pin held on two buffers i.e. bucket buf and current buf which is basically overflow buf. My guess (which could be wrong) is that so->hashso_bucket_buf = > InvalidBuffer should be moved back up higher in the function where it > was before, just after the first if statement, and that the new > condition so->hashso_bucket_buf == so->currPos.buf on the last > _hash_dropbuf() should be removed. If that's not right, then I think > I need somebody to explain why not. Okay, as i mentioned above, in case of page scan mode we only keep pin on a bucket buf. There won't be any case where we will be having pin on overflow buf at the end of scan. So, basically _hash_dropscan buf() should only attempt to release pin on a bucket buf. And an attempt to release pin on so->currPos.buf should only happen when 'so->hashso_bucket_buf == so->currPos.buf' or when 'so->hashso_split_bucket_buf == so->currPos.buf' > > I am suspicious that _hash_kill_items() is going to have problems if > the overflow page is freed before it reacquires the lock. > _btkillitems() contains safeguards against similar cases. I have added similar check for hash_kill_items() as well. > > This is not a full review, but I'm out of time for the moment. No worries. I will be ready for your further review comments any time. Thanks for the review. -- With Regards, Ashutosh Sharma EnterpriseDB:http://www.enterprisedb.com
Вложения
В списке pgsql-hackers по дате отправления: