Skip to content
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

When saving a data object, index definitions are not applied to the object_query table. #5031

Closed
andreas-gruenwald opened this issue Sep 30, 2019 · 5 comments · Fixed by #5081
Assignees
Labels

Comments

@andreas-gruenwald
Copy link
Contributor

andreas-gruenwald commented Sep 30, 2019

Bug Report

In my product's class definition there is a field called "remoteId". I recognized performance issues in relation with the product, so I revised the field's index definition:

First of all, the field is marked as "unique", so I assumed that the database definition (object_query_product) would contain a key with a "unique index" definition, or at least a non-unique index. However this was not the case.

Expected behavior

  • index flag creates a SQL index for the field "remoteId" in the object_store table.
  • index flag creates a SQL index for the field "remoteId" in the object_query table.
  • unique flag creates a SQL "unique" index constraint for the field "remoteId" in the object_store table.
  • unique flag creates a SQL "non-unique" index constraint for the field "remoteId" in the object_query table (as unique in query_tables is a too big constraint).

Actual behavior

  • Indices are created for the store tables, but no index is created for the query table at all.

Steps to reproduce

  • Create a product class.
  • add a text field named "remoteId".
  • Save the class definition.
  • Make some changes.
  • Edit the class definition and mark the field as "unique" and "index".
  • Index is not updated (may require that there are many products/objects in Pimcore).

Pimcore Version

Your Version: v5.8.0

@andreas-gruenwald
Copy link
Contributor Author

andreas-gruenwald commented Oct 1, 2019

I just figured out, that in DataObject\ClassDefinition\Dao.php the unique key is only applied to the object_store table, not to the object_query table. If a key is defined as "unique", then in the object_query_table no key is defined at all. Does that mean that JOIN statements always should be applied on the store table?

see https://github.com/pimcore/pimcore/blob/master/models/DataObject/ClassDefinition/Helper/Dao.php#L44: enabled is false in my case for the object_query table.

@fashxp
Copy link
Member

fashxp commented Oct 1, 2019

hmm, cannot be reproduced on demo application.

on which table are you checking?

@andreas-gruenwald
Copy link
Contributor Author

andreas-gruenwald commented Oct 1, 2019

Please see my screenshot:
$considerUniqueIndex is false for the table "object_query_product", so both, unique index, and index are getting disabled, if both "index" and "unique" are selected. If only "unique" is selected, then it seems that also no index is set on the object_query_product table.

image

Is this on purpose? In my opinion, the query table should at least receive an (non-unique) index.

@andreas-gruenwald
Copy link
Contributor Author

andreas-gruenwald commented Oct 10, 2019

@weisswurstkanone Issue description updated.

@andreas-gruenwald andreas-gruenwald changed the title When saving a data object, index definitions for a field are not saved. When saving a data object, index definitions are not applied to the object_query table. Oct 10, 2019
@weisswurstkanone
Copy link
Contributor

just as a reference but not directly related to it
#2943

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants