You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this case we have a many-to-many relation, and we create an extra table for the relations:
Table "_FriendShip"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
A | integer | | not null |
B | integer | | not null |
And a few constraints:
Indexes:
"_FriendShip_AB_unique" UNIQUE, btree ("A", "B")
Foreign-key constraints:
"_FriendShip_A_fkey" FOREIGN KEY ("A") REFERENCES "User"(id) ON UPDATE CASCADE ON DELETE CASCADE
"_FriendShip_B_fkey" FOREIGN KEY ("B") REFERENCES "User"(id) ON UPDATE CASCADE ON DELETE CASCADE
Now everything works fine when selecting the friendWith attribute, due to us doing a search with the column A. But when using the friendOf attribute, we suddenly query the table from the column B causing a sub-optimal performance.
We should always add an additional index for the column B to prevent situations like this.
The text was updated successfully, but these errors were encountered:
Let's imagine a model:
In this case we have a many-to-many relation, and we create an extra table for the relations:
And a few constraints:
Now everything works fine when selecting the
friendWith
attribute, due to us doing a search with the columnA
. But when using thefriendOf
attribute, we suddenly query the table from the columnB
causing a sub-optimal performance.We should always add an additional index for the column
B
to prevent situations like this.The text was updated successfully, but these errors were encountered: