-
-
Notifications
You must be signed in to change notification settings - Fork 315
Allow to search builds by hash #654
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
Conversation
Currently, a full store path has to be provided to search in builds. This patch permits to search jobs with a output path or derivation hash. Usecase: we are building Docker images with Hydra. The tag of the Docker image is the hash of the image output path. This patch would allow us to find back the build job from the tag of a running container image.
Note I really don't know what could be the performance impact on search queries on hydra.nixos.org... Of course, on my Hydra instances, it's negligible. |
Yeah it seems that this could require a sequential scan on the |
I confirm using a regex to search by
|
@edolstra We could create indexes supporting
What do you think? |
The search query uses the LIKE operator which requires a sequential scan (it can't use the already existing B-tree index). This new index (trigram) avoids a sequential scan of the builds table when the LIKE operator is used. Here is the analyze of a request on the builds table with this index: explain analyze select * from builds where drvpath like '%k3r71gz0gv16ld8rhcp2bb8gb5w1xc4b%'; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------- Bitmap Heap Scan on builds (cost=128.00..132.01 rows=1 width=492) (actual time=0.070..0.077 rows=1 loops=1) Recheck Cond: (drvpath ~~ '%k3r71gz0gv16ld8rhcp2bb8gb5w1xc4b%'::text) -> Bitmap Index Scan on indextrgmbuildsondrvpath (cost=0.00..128.00 rows=1 width=0) (actual time=0.047..0.047 rows=3 loops=1) Index Cond: (drvpath ~~ '%k3r71gz0gv16ld8rhcp2bb8gb5w1xc4b%'::text) Total runtime: 0.206 ms (5 rows)
I added the creation of this index in the commit 7935cff. |
How much disk space does the trigram index need? |
Hm, I didn't find clear doc about the disk usage of this kind of In the following, I ran Postgresql 11.3 on my laptop (4 cores, 16G RAM).
The size of /var/lib/postgresql/data is 1.8G. The query
took about 1.5s to execute. Then I created the For a table containing
I'm not sure what to conclude... It seems it consumes something close |
It has ~90 million rows. You can use
|
For a table containing
|
Thanks, that sounds like a still acceptable increase. |
Thx! |
@nlewo when searching like this are you searching for partial hashes or full hashes? |
Currently, a full store path has to be provided to search in
builds. This patch permits to search jobs with a output path or
derivation hash.
Usecase: we are building Docker images with Hydra. The tag of the
Docker image is the hash of the image output path. This patch would
allow us to find back the build job from the tag of a running
container image.