MDL-66327 pgsql DML: Update get_records_sql to consume less memory
authorAndrew Nicols <andrew@nicols.co.uk>
Thu, 8 Aug 2019 06:03:41 +0000 (14:03 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Thu, 8 Aug 2019 07:48:12 +0000 (15:48 +0800)
commit66fa73d84e4e6d3b80cc1603bc3e4ee72ab75380
treed75ed495b1e1e8b80fbac33cab44287f5e485dd2
parent414eca89239d275807f155837e10200f9e81322a
MDL-66327 pgsql DML: Update get_records_sql to consume less memory

It's more memory efficient to use `pg_fetch_assoc` for each row than to
call `pg_fetch_all` and release memory immediately. This is because we
can treat the assoc fetch like an iterator and it only fetches the
current record into memory one at a time, whilst the all fetch fetches
all records and never unsets them. Attempting to unset them is extremely
time consuming.
lib/dml/pgsql_native_moodle_database.php