Query causes RAM usage spike
Bug #646898 reported by
Andrew Hutchings
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Drizzle |
Fix Released
|
High
|
Stewart Smith | ||
7.0 |
Fix Released
|
High
|
Stewart Smith |
Bug Description
The following query spikes to 1.8G resident RAM usage (assumes you have test.t1 existing):
SELECT * FROM DATA_DICTIONARY
This is only when using the ORDER BY, otherwise it stays at 50MB.
Related branches
lp:~stewart/drizzle/bug646898-functionengine-mem-usage-position
- Drizzle Developers: Pending requested
-
Diff: 137 lines (+68/-11)2 files modifiedplugin/function_engine/cursor.cc (+62/-9)
plugin/function_engine/cursor.h (+6/-2)
Changed in drizzle: | |
status: | New → Confirmed |
Changed in drizzle: | |
importance: | Undecided → Critical |
To post a comment you must log in.
This bug is because of the position function in the FunctionCursor class. This function looks like:
void FunctionCursor: :position( const unsigned char *record) getShare( )->getRecordLen gth()) cache.resize( row_cache. size() + table-> getShare( )->getRecordLen gth() * 100); // Hardwired at adding an additional 100 rows of storage &row_cache[ record_ id * table-> getShare( )->getRecordLen gth()], record, table-> getShare( )->getRecordLen gth()); :my_store_ ptr(ref, ref_length, record_id);
{
if (row_cache.size() <= record_id * table->
{
row_
}
memcpy(
internal:
record_id++;
}
For the columns table in the data dictionary, the getRecordLength() function returns the value 81132. The columns table in drizzle has 510 rows by default. Thus, if you issue this query:
select * from data_dictionary .columns order by ordinal_position
the row_cache vector will get to be of size:
81132 * 100 * 5 = 40566000
The vector is of unsigned chars so we multiply by 8 to get bytes:
40566000 * 8 = 324528000 bytes = 324 MB
Thus, the query requires 324 MB of memory to be allocated when an ORDER BY clause is used.