the latest update to the print modules uses an really ineffective method to update or inset rows in the database. Sites with large node tables may exceed max execution time limits or memory limits in PHP. Also, the way the SQL is written breaks in PostgreSQL.

The suggested patch improves the performance of the update significantly and is PostgreSQL SQL compliant.

Comments

josh waihi’s picture

StatusFileSize
new5.63 KB

there were a few bugs in my last patch. here it is again tested and working.

jcnventura’s picture

Version: 6.x-1.x-dev » 6.x-1.11
Status: Needs review » Needs work

Hi,

The logic is wrong. Instead of GREATEST (OR), GREATEST (OR), GREATEST (OR) it should be AND, IMP, AND. IMP stands for material implication which can be implemented as OR(NOT(x), y).

Also, doesn't this spew out lots of errors for the failed insert? Which is wrong also, as it should be nid, $print_display, $print_display_comment, $print_display_urllist and not nid, 0, 0, 1.

Finally, there's already some code in 6.x-1.12 to try to reduce this. I would love to have code that's more performant AND PostgreSQL compatible, but it must start by being correct.

Thanks for providing a patch!

João Ventura

sammys’s picture

Status: Needs work » Needs review
StatusFileSize
new2.67 KB

While we're waiting for the performance enhancement I'd like to have a fix committed for PostgreSQL to update without error since that's more critical than performance. Here is a patch to do just that.

I would expect this issue to be reset to needs work after that commit. :)

jcnventura’s picture

Status: Needs review » Needs work

sammys: that fix was committed more than a month ago (#881870: last update_n doesn't work in postgres)

dalin’s picture

update 6007 barfs on any site with a moderate number of nodes due to an out-of-memory error. I think we need to use batch API to get this to complete reliably. Some code comments would be great - I can't even figure out what the code is trying to do.

dalin’s picture

Even when I hard-code
ini_set('memory_limit', '256M');
at the beginning of the update, another memory error when update.php tries to output the results due to the massive number of queries run. I had to switch to db_query instead of udpate_sql().

jcnventura’s picture

Status: Needs work » Fixed

I am so sorry, everyone..

Looking at this again, I realized the operations are AND, OR, AND (not AND, IMP, AND) as I believed in #2.

That sequence of operations is very simple to implement in standard SQL that is valid in MySQL and PostgreSQL, and after some other fixes which dispense with the INSERT operation, the 6007 updates can become a lot simpler..

If anyone still cares, feel free to try the dev.

João

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.