Hello everybody,
i'm new to the forum, so sorry if i'm missing some rules, or access notion. This is my first attempt to create a big application.
i have this database with a complex table (STORICO_PDV) of over 90 fields and more than 140.000 records growing.
The index i have built are:
PERIODORIF (Date/time) in english is like "Date"
AREA (Text) a value between 12 different possibilities
PrimaryKey (Counter) a sort of transaction id
and others, not used in this query
i need to run a query to Sum 2 fields of this table grouping by a an other field called MCC
the records to sum are selected via a form which asks for:
AREA and PERIODORIF and other minor values.
the SQL code access generate is the following:
Code:
SELECT STORICO_PDV.MCC, mcc_desc.DESC_MCC, Sum(STORICO_PDV.TOT_VOLUMI_TRANSATI) AS SommaDiTOT_VOLUMI_TRANSATI, Sum(STORICO_PDV.TOT_REDDITIVITA) AS TOT_REDDITIVITA
FROM mcc_desc INNER JOIN STORICO_PDV ON mcc_desc.MCC = STORICO_PDV.MCC
WHERE
((([AREA]=[Forms]![Vista X Aree]![AREA] Or [Forms]![Vista X Aree]![AREA] Is Null)=True)
AND
(([PERIODORIF] Between [Forms]![Vista X Aree]![MeseInizio] And [Forms]![Vista X Aree]![MeseFine] Or [Forms]![Vista X Aree]![MeseInizio] Is Null Or [Forms]![Vista X Aree]![MeseFine] Is Null)=True)
AND
((IIf([Forms]![Vista X Aree]![Segno] Is Null Or [Forms]![Vista X Aree]![Rating] Is Null,True,IIf([RATING] Is Null,Null,Eval([RATING] & [Forms]![Vista X Aree]![Segno] & [Forms]![Vista X Aree]![Rating]))))=True)
AND
(([FIS_VIR]=[Forms]![Vista X Aree]![FISVIR] Or [Forms]![Vista X Aree]![FISVIR] Is Null)=True))
GROUP BY STORICO_PDV.MCC, mcc_desc.DESC_MCC;
Now my problem is that the query run EXTREMLY slow the first time i run it and then a bit faster the next times, until the database is exited and cleaned. Is there a way to optimize it?
thanks for your precious help!
Cisco