-
-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize inserting keywords into tl_search_index #1277
Comments
|
Are you sure about the database quoting? Also, why mix the two connections and not just use Doctrine? |
|
On a similar note, this can be done just with the legacy class. // Remove existing index
$objDatabase->prepare("DELETE FROM tl_search_index WHERE pid=?")
->execute($intInsertId);
$arrQuery = array();
$arrValues = array();
foreach ($arrIndex as $k=>$v)
{
$arrQuery[] = '(%s, %s, %s, %s)';
$arrValues[] = (int) $intInsertId;
$arrValues[] = $k;
$arrValues[] = $v;
$arrValues[] = $arrData['language'];
}
// Create the new index
$objDatabase->prepare("INSERT INTO tl_search_index (pid, word, relevance, language) VALUES " . implode(', ', $arrQuery))->execute($arrValues); |
|
I am sure that we should quote the values if that is what you mean. 😄 We might as well use only Doctrine of course. Or add a The code was just a quick fix for contao.org. |
|
I don't like your second solution. It works for sure, but we are building two possibly giant arrays that consume a lot of memory for nothing. |
|
Really? Counting the characters, I think |
|
Except your approach requires a lot of |
|
It requires one, instead of multiple |
|
Sorry, I meant it requires a giant |
|
If the (I'd be more concerned about possible injections. ) |
|
It seems that one giant |
|
Implemented in 6f8a020. |
|
First of all: I'm fine with the changes as this really makes things faster. :D And I really don't want to nitpick but rather raise awareness that those tests should probably better be profiled inside the application. If you for instance swap the execution order of the two tested versions (https://3v4l.org/lvnqS) the already small differences (overall same magnittude) gets even smaller showing that these tests are in no way free of side effects. |
Description ----------- See #1277 Commits ------- c999f8e5 Roll back route name
Using a combined insert query to add the keywords to tl_search_index will greatly improve the performance.
I was able to rebuild the search index on contao.org in about 2 minutes compared to over 10 minutes before.
@contao/developers Shall we change this in Contao 4.4 as well?
The text was updated successfully, but these errors were encountered: