Skip to content

feat: use temporary table instead of large IN query in PilotAgentsDB - #8779

Draft
chaen wants to merge 2 commits into
DIRACGrid:integrationfrom
chaen:v9.1_feat_pilot_in_query
Draft

feat: use temporary table instead of large IN query in PilotAgentsDB#8779
chaen wants to merge 2 commits into
DIRACGrid:integrationfrom
chaen:v9.1_feat_pilot_in_query

Conversation

@chaen

@chaen chaen commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

BEGINRELEASENOTES

*WMS

CHANGE: use temporary table instead of large IN statement in PilotAgentsDB

ENDRELEASENOTES

@chaen
chaen force-pushed the v9.1_feat_pilot_in_query branch from 0469a7d to c4d527e Compare September 8, 2026 15:21
@chaen
chaen force-pushed the v9.1_feat_pilot_in_query branch from c4d527e to 1a65ad7 Compare September 8, 2026 15:49
@aldbr

aldbr commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

I am not fully sure to understand what you are trying to solve exactly here, can you provide further details please?

I assume it's because of:

result = self.pilotDB.selectPilots(
{"Status": PilotStatus.PILOT_TRANSIENT_STATES}, older=timeLimitToConsider, timeStamp="LastUpdateTime"
)
if not result["OK"]:
self.log.error("Failed to get the Pilot Agents")
return result
if not result["Value"]:
return S_OK()
refList = result["Value"]
result = self.pilotDB.getPilotInfo(refList)
if not result["OK"]:
self.log.error("Failed to get Info for Pilot Agents")
return result

If it's the case, I am wondering why we don't just simplify by having a getPilotInfoForSelection method (merging selectPilots and getPilotInfo into a single SQL request). Or even having selectPilots returning any pilot information? (that would make a breaking change in the API here)

@chaen

chaen commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

the problem is the query itself.

select * from Table where column in (1,2,3,4,...,126456464)

is not efficient.

On the other hand, this is very fast

create temporary table tmp_table(column INT PRIMARY KEY);
insert into tmp_table (column) values (1),(2),(3),(4),...,(126456464);
select * from table t join temporary table tt on t.column = tt.column;

Of course, it's for large number of values.

@aldbr

aldbr commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

the problem is the query itself.

select * from Table where column in (1,2,3,4,...,126456464)

is not efficient.

This I understand, but it looks like the query itself could be avoided by returning the pilot info instead of just the pilot reference from selectPilots(), unless I am missing some details

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.

2 participants