Skip to content

Commit 1bfa6c5

Browse files
committed
improve next crawl nodes query
1 parent 0bf6163 commit 1bfa6c5

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

pkg/database/disc.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,19 @@ func (db *DB) fetchExecutionNodesToCrawl(ctx context.Context) error {
218218
rows, err := db.pg.Query(
219219
ctx,
220220
`
221+
WITH last_crawled AS (
222+
SELECT node_id
223+
FROM crawler.next_disc_crawl
224+
WHERE last_found > now() - INTERVAL '48 hours'
225+
)
221226
SELECT
222227
next_node_crawl.next_crawl,
223228
node_record
224229
FROM crawler.next_node_crawl
225-
LEFT JOIN disc.nodes USING (node_id)
226-
LEFT JOIN crawler.next_disc_crawl USING (node_id)
230+
INNER JOIN crawler.next_disc_crawl USING (node_id)
231+
INNER JOIN disc.nodes USING (node_id)
227232
WHERE
228233
next_node_crawl.node_type IN ('Unknown', 'Execution')
229-
AND last_found > now() - INTERVAL '48 hours'
230234
ORDER BY next_node_crawl.next_crawl
231235
LIMIT 1024
232236
`,

0 commit comments

Comments
 (0)