plus order in subselect won't be taking into account. subselect (IN) does
not respect order of IDs.
Dne čtvrtek 29. července 2021 v 19:21:26 UTC+2 uživatel Michal Macejko
napsal:
> nodes.select{members[:id]}.distinct.from_self.limit(50)
>
> where nodes are: nodes =
> current_account.members_dataset.eager_graph(member_integrations:
> [:member_integration_fields])
>
> fails on PG::InvalidColumnReference: ERROR: for SELECT DISTINCT, ORDER BY
> expressions must appear in select list
>
> not sure i can combine DISTINCT width ORDER BY that easily
>
> Dne čtvrtek 29. července 2021 v 18:30:06 UTC+2 uživatel Jeremy Evans
> napsal:
>
>> On Thu, Jul 29, 2021 at 9:21 AM Michal Macejko <[email protected]>
>> wrote:
>>
>>> Unfortunately 600/100 counts are just from my local machine. The
>>> production table growing really fast.
>>>
>>> I'm afraid that the denormalization is not possible in this case, as
>>> MemberIntegrationFields are very dynamic.
>>>
>>> I'm running more tests in ActiveRecord and it was just a luck that it
>>> worked there.
>>>
>>> :Member.includes(member_integrations:
>>> [:member_integration_fields]).order('member_integration_fields.id
>>> ').limit(50).count
>>>
>>> returns 43.
>>>
>>> Any other idea, how to fetch these members?
>>>
>>
>> Assuming you want 50 members and not 43, did you try the suggestion I
>> gave with the subselect:
>>
>> nodes.where{|o| o.members[:id] =~ nodes.select{members[:id]}.
>> distinct.from_self.limit(50)}
>>
>> Thanks,
>> Jeremy
>>
>
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sequel-talk/16366eed-3702-47a4-b288-a5ed0156ab87n%40googlegroups.com.