Hello Mark, -That is not surprising. You are executing a query and for each row you are -executing another query. Use joins and/or subqueries instead.
-Mark Sometimes, there is the normalization of the database a disadvantage. I should save the timestamp and data in one table, so I save the time in one and the ID of the time in the second table with data, because for each time I save 20+ records (values). I need for each time (per hour, per day, per month) only one row returned and in the data-field all items like (item1:sumofitem1;item2:sumofitem2;…) Very fast is the following statement: for select extract (day from a.messzeit) || '.' || extract (month from a.messzeit) || '.' || extract(year from a.messzeit) || ' ' || extract(hour from a.messzeit) || ':00:00' as mz, b.id_zaehler, sum(b.wert) from te_messzeiten a left join te_werte b on a.id = b.id_messzeit where a.messzeit >= :zr_von and a.messzeit < :zr_von + 1 group by mz, b.id_zaehler into :messzeit, :messwerte, :messwerte2 do suspend; (zr_von is the condition (timestamp)) But in this case I get for each item and each time a record returned. This is not what I need. What solution can I use for a faster result? (It should be, vor example group by day: 2014-01-01 01:00:00 01:100,0;02:199,1;03:222,9 (grouped for each hour for the day for each item) 2014-01-01 02:00:00 01:300,0;02:198,1;03:211,7 Source: Table a ID;Timestamp 1; 2014-01-01 01:00:00 2; 2014-01-01 01:10:00 3; 2014-01-01 01:20:00 Table b ID;ID_TableA;Item;Value 1;1;10;0.32 2;1;11;0.44 3;1;12;1.22 4;2;10;0.39 5;2;11;0.45 6;2;12;1.21 Thank you _____ Posted by: Mark Rotteveel < <mailto:m...@lawinegevaar.nl> m...@lawinegevaar.nl> _____ <https://groups.yahoo.com/neo/groups/firebird-support/conversations/messages/125865;_ylc=X3oDMTJyMmNjNTQ4BF9TAzk3MzU5NzE0BGdycElkAzI0NDI0MDYEZ3Jwc3BJZAMxNzA1MTE1Mzg2BG1zZ0lkAzEyNTg2NQRzZWMDZnRyBHNsawNycGx5BHN0aW1lAzE0MTg2NTYwOTQ-?act=reply&messageNum=125865> Reply via web post • <mailto:m...@lawinegevaar.nl?subject=Re%3A%20%5Bfirebird-support%5D%20Performance%20optimation%3F> Reply to sender • <mailto:firebird-support@yahoogroups.com?subject=Re%3A%20%5Bfirebird-support%5D%20Performance%20optimation%3F> Reply to group • <https://groups.yahoo.com/neo/groups/firebird-support/conversations/newtopic;_ylc=X3oDMTJlbnZydWRiBF9TAzk3MzU5NzE0BGdycElkAzI0NDI0MDYEZ3Jwc3BJZAMxNzA1MTE1Mzg2BHNlYwNmdHIEc2xrA250cGMEc3RpbWUDMTQxODY1NjA5NA--> Start a New Topic • <https://groups.yahoo.com/neo/groups/firebird-support/conversations/topics/125864;_ylc=X3oDMTM4ZDhnazMxBF9TAzk3MzU5NzE0BGdycElkAzI0NDI0MDYEZ3Jwc3BJZAMxNzA1MTE1Mzg2BG1zZ0lkAzEyNTg2NQRzZWMDZnRyBHNsawN2dHBjBHN0aW1lAzE0MTg2NTYwOTQEdHBjSWQDMTI1ODY0> Messages in this topic (2) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Visit http://www.firebirdsql.org and click the Documentation item on the main (top) menu. Try FAQ and other links from the left-side menu there. Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ <https://groups.yahoo.com/neo/groups/firebird-support/info;_ylc=X3oDMTJlY2tvZm8yBF9TAzk3MzU5NzE0BGdycElkAzI0NDI0MDYEZ3Jwc3BJZAMxNzA1MTE1Mzg2BHNlYwN2dGwEc2xrA3ZnaHAEc3RpbWUDMTQxODY1NjA5NA--> Visit Your Group * <https://groups.yahoo.com/neo/groups/firebird-support/members/all;_ylc=X3oDMTJmbzJvcXRoBF9TAzk3MzU5NzE0BGdycElkAzI0NDI0MDYEZ3Jwc3BJZAMxNzA1MTE1Mzg2BHNlYwN2dGwEc2xrA3ZtYnJzBHN0aW1lAzE0MTg2NTYwOTQ-> New Members 5 <https://groups.yahoo.com/neo;_ylc=X3oDMTJkYXMycnV2BF9TAzk3MzU5NzE0BGdycElkAzI0NDI0MDYEZ3Jwc3BJZAMxNzA1MTE1Mzg2BHNlYwNmdHIEc2xrA2dmcARzdGltZQMxNDE4NjU2MDk0> • <https://info.yahoo.com/privacy/us/yahoo/groups/details.html> Privacy • <mailto:firebird-support-unsubscr...@yahoogroups.com?subject=Unsubscribe> Unsubscribe • <https://info.yahoo.com/legal/us/yahoo/utos/terms/> Terms of Use . <http://geo.yahoo.com/serv?s=97359714/grpId=2442406/grpspId=1705115386/msgId=125865/stime=1418656094> <http://y.analytics.yahoo.com/fpc.pl?ywarid=515FB27823A7407E&a=10001310322279&js=no&resp=img>