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

Port Rails 6 time fix #2

Closed
wants to merge 6 commits into from
Closed

Port Rails 6 time fix #2

wants to merge 6 commits into from

Conversation

dtcristo
Copy link
Member

@dtcristo dtcristo commented Jun 4, 2020

In Rails 6 we get no implicit conversion of Time into String when enqueueing jobs. This was patched upstream, see here.

xaviershay and others added 6 commits May 29, 2019 15:43
It's relatively easy for this to happen by accident (e.g. time drift on
a rogue server), and it throws a spanner in the works if you're
monitoring for oldest job in the queue.
This method wasn't making use of the que_jobs.args index and was
performing badly on large datasets.

GIN indexes don't support the '=' operator, but support existence '?'
and containment '@>' among others. To make use of the index the query
has to check for containment of a subset document rather than match a
value within the document directly.

QueJob#by_job_args is already querying in this way; this change makes
QueJob#by_job_class consistent with it.

Context:

https://www.postgresql.org/docs/9.6/datatype-json.html#JSON-INDEXING

Given a jsonb column "data" indexed as follows:
  CREATE INDEX data_index ON table USING GIN (data);

And with data in this format:
  {
    "name": "Melbourne",
    "type": "City"
  }

This query will make use of the index:
  SELECT data FROM table WHERE data @> '{"name": "Melbourne"}';

But this one will not:
  SELECT data FROM table WHERE data->>'name' = "Melbourne";
Improve QueJob#by_job_class performance.
In Rails 6 we get `no implicit conversion of Time into String` when enqueueing jobs. This was patched upstream, see [here](que-rb#247).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants