Hi,
I have a small database with about 45,000 rows of all tables.
I'm using other names for the tables here. They look like this:
users
└── threads
└── posts
For user #9, they have about 80 threads, 80 posts. Running this inside
MariaDB interactive command line is very fast (<= 1 second):
-- for user #9: delete threads without any posts
delete from threads where user_id=9 and id not in (select thread_id from
posts where user_id=9);
But using Sequel, it took ~ 6 minutes:
@db[:threads]
.where(:id => @db[:posts].distinct.where(:user_id =>
9).select(:thread_id))
.invert()
.where(:user_id => 9)
.delete()
Would you please help me with a better Sequel usage for my goal?
Thank you,
--
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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.