Ask your Symfony questions! Pay money and get answers fast! (more info)

Anyway to have a foreign key against a table with too many rows? Symfony

  • SOLVED

Look at the screenshot. I'm getting:

<blockquote>Wine
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 16 bytes) in /home/lkrubner/dev/tastingnotes/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Hydrator/Graph.php on line 271</blockquote>

This is on a table that has a field called wine_id. This is a foreign relation to another table, which has 250,000 rows. I assume that looking up that many rows exhausts the memory.

I'm using Symfony 1.4 and Doctrine. Is there any way to make this foreign relationship work, or do I need to give up on it?

There are 2 tables:

wine

note

Note belongs to wine. The field "wine_id" links them.

You can see the schema for note here:






Note:
connection: doctrine
tableName: note
columns:
id:
type: integer(8)
fixed: false
unsigned: false
primary: true
autoincrement: true
bottle_two:
type: integer(1)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
bot_code:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
bot_code_b:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
case_type:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
ccode:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
copy_edit_date_first:
type: date
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
copy_edit_date_second:
type: date
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
copy_edit_note_first:
type: string()
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
copy_edit_note_second:
type: string()
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
copy_editor_first:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
corked:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
created:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
curprice:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
cycle:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
date_recvd:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
drink_recom:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
drink_recom_b:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
early_tasting:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
edited:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
finished:
type: integer(1)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
flight:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
flight_b:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
flight_bottle:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
hot_wine:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
label:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
latest_note:
type: string()
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
office:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
order_number:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
price:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
rating:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
rating2:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
recor_id:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
record_num_curr:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
rt_ok:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
rtcount:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
rtmark:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
rtscore:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
sav_rdate:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
score:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
score_b:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
score_b:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
setup:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
tasc:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
tastedate_b:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
taster:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
taster_b:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
tastetext:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
tasting_id:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
tca:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
tca_final:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
tcat:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
td:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
td_b:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
tyear1:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
tyear1_b:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
tyear2:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
tyear2_b:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
winecode:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
wnycode:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
export_record_id:
type: interger(11)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
cen:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
bot_2nd_request:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
cey:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
date_requested:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
early_tasting_id:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
late_tasting_id:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
tasting_highlights:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
tasting_id_b:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
wine_id:
type: integer(8)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
note_for_public:
type: string()
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
note_for_internal_use:
type: string()
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
created_by:
type: integer(8)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
updated_by:
type: integer(8)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
created_at:
type: timestamp(25)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
updated_at:
type: timestamp(25)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
tasting_group_id:
type: integer(8)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
export_record_from_filemaker_id:
type: integer
relations:
Wine:
local: wine_id
foreign: id


Answers (2)

2011-01-02

Joshua Estes answers:

What does the code in your form class look like?


Joshua Estes comments:

It looks like you are trying to create a select list widget that links to the wine. One way that I have found to get around this is to use the sfFormExtraPlugin http://www.symfony-project.org/plugins/sfFormExtraPlugin and use the autocomplete widget.

2011-01-03

Loban Rahman answers:

This is an example of a case where you should not be hydrating the object. In order to create the select list widget, all you need is the "id" and "name". So modify the sql query for the widget to get a list of all wine's but only get an array with id and name, no hydration. This will drastically reduce the memory needed.

Combining this technique with Joshua's technique above is also a good idea.