I have the following 3 selects and I want to improve performance, what can I do?
select object into lastUpdate
from data
where predicate = '#lastUpdate'
and subject = 'subject1';
select object into latitude
from data
where predicate = '#latitude'
and subject = 'subject1';
select object into longitude
from data
where predicate = '#longitude'
and subject = 'subject1';
Thank you
CodePudding user response:
You can use a JOIN:
select lu.object, lat.object, lon.object
into lastupdate, latitude, longitude
from data lu
left join data lat on lat.subject = lu.subject and lat.predicate = '#latitude'
left join data lon on lon.subject = lu.subject and lon.predicate = '#longitude'
where lu.subject = 'subject1'
and lu.predicate = '#lastUpdate';