| Index
» Projekty
» phpMyEdit
» Fórum
» Lesson in Filters, Join Creates Excess Data |
 |
reber
Založený: 23.06.2003
Príspevky: 10
Zaslal: 2004-04-15 04:16
Návrat hore
Odpovedať s citátom
|
Hello all,
I've finally mastered the ability to show fields from two different but related tables.
My particular problem now is that the foreign key has 8,000 entries which causes PME to load slowly.
Is there a filter stragegy to reduce the number of combinations resulting from the join? Maybe another approach is needed?
The code below illustrates my need, a simple check for valid email addresses. (Of course, there may be an easier way.) Column1 reads table0 and Column2 returns an entry from table1 if the fkey is a match.
So, the question remains, can the output be filtered to avoid timeout?
| Kód: |
$opts['fdd']['id'] = array(
'name' => 'ID',
'select' => 'T',
'options' => 'H', // auto increment
'maxlen' => 25,
'default' => '0',
'sort' => true
);
$opts['fdd']['wmail'] = array(
'name' => 'Entered E-mail',
'select' => 'T',
'maxlen' => 25,
'required' => true,
'options' => 'RLV',
'sort' => true
);
//JOIN... (fky lookup wmail_to_email)
$opts['fdd']['wmail']['values']['table'] = 'members_directory';
$opts['fdd']['wmail']['values']['column'] = 'email';
$opts['fdd']['wmail']['values']['description'] = 'email';
//dummyfield of 2nd table (members_directory)
//join alread exists of field above...
$opts['fdd']['hold0'] = array(
'name' => 'Returned E-mail',
'sql' => 'email',
'select' => 'T',
'maxlen' => 25,
'required' => true,
'options' => 'RLV',
'sort' => true
);
// Now important call to phpMyEdit
require_once 'phpMyEdit.class.php';
new phpMyEdit($opts);
?> |
|
ajh
Založený: 17.12.2003
Príspevky: 236
Zaslal: 2004-04-15 07:13
Návrat hore
Odpovedať s citátom
|
Yes - ['values']['filters'] but I suspect that this won't help with a large join.
The CVS version of PME has a ['values']['join'] option that allows you to better refine what the join should actully be.
By the way - you have indexed the email column in the lookup table haven't you? :-)
|
reber
Založený: 23.06.2003
Príspevky: 10
Zaslal: 2004-04-15 16:33
Návrat hore
Odpovedať s citátom
|
Thanks for responding ajh,
| Citácia: |
| Yes - ['values']['filters'] but I suspect that this won't help with a large join. |
I tried a number of combinations but haven't had much luck. I'll look at my log (haven't done that before) to improve my chances that I'm referencing the correct fields.
| Citácia: |
| The CVS version of PME has a ['values']['join'] option that allows you to better refine what the join should actully be. |
Nice! I think. Is this documented for the inexperienced?
| Citácia: |
| By the way - you have indexed the email column in the lookup table haven't you? :-) |
I'm glad you asked. I don't know what you mean, so I probably haven't done this. Please explain!
thx/Reber
|
ajh
Založený: 17.12.2003
Príspevky: 236
Zaslal: 2004-04-15 17:07
Návrat hore
Odpovedať s citátom
|
You'll need to get the documentation from the CVS - it's a bit fiddly to read but it's there. Effectively you have to write the bit of the SQL WHERE clause that makes MySQL do what you want.
You might want to read the MySQL documentation on indexing. Basically you can create an index on any column in a MySQL table. It then uses this index to optimise the query. It's a MySQL thing rather than a PME thing. Have a look here:
http://dev.mysql.com/doc/mysql/en/MySQL_indexes.html
Probably something like:
| Kód: |
| CREATE INDEX ix_1 ON members_directory(email) |
It will automatically get used if it exists, you don't need to do anything in PME.
|
hbernard
Založený: 23.03.2003
Príspevky: 159
Bydlisko: FRANCE
Zaslal: 2004-04-16 08:06
Návrat hore
Odpovedať s citátom
|
| reber Napísal: |
| Citácia: |
| Yes - ['values']['filters'] but I suspect that this won't help with a large join. |
I tried a number of combinations but haven't had much luck. I'll look at my log (haven't done that before) to improve my chances that I'm referencing the correct fields.
...
|
If you are experiencing sql errors when trying to make custom filters, you may set
| Kód: |
| $debug_query = true; |
in the calling script.
Then, PME will output all the query it make.
But I really think you trouble here is related to index, as ajh pointed out.
(I'm using PME with joins between tables with about 20000 records, and I have no performance issue.)
http://dev.mysql.com/doc/mysql/en/SELECT_speed.html
is a good starting point.
_________________ hbernard - phpMyEdit updater.
|
reber
Založený: 23.06.2003
Príspevky: 10
Zaslal: 2004-04-21 21:56
Návrat hore
Odpovedať s citátom
|
Indexing the tables has made ALL the difference.
Thanks to ajh and hbernard for your input on this issue.
PME is a remarkably versatile tool. My thanks to all who contribute to it.
|
ajh
Založený: 17.12.2003
Príspevky: 236
Zaslal: 2004-04-22 08:26
Návrat hore
Odpovedať s citátom
|
Glad it helped!
|
|
Odoslať novú tému
Odpovedať na tému
|
|
|
|