optimizing the query.
HELLO
WE HAVE A TABLE NAME 'ACC' WHICH HAVE FOLL COLUMNS:
sip_from (datatype is varchar(128))
sip_to (datatype is varchar(128)),
sip_status (datatype is varchar(128)),
sip_method (datatype is varchar(16)),
i_uri (datatype is varchar(128)),
o_uri (datatype is varchar(128)),
from_uri (datatype is varchar(128)),
to_uri (datatype is varchar(128)),
sip_callid (datatype is varchar(128)),
username (datatype is varchar(64)),
domain (datatype is varchar(128)),
fromtag (datatype is varchar(128)),
totag (datatype is varchar(128)),
time (datetime),
timestamp (timestamp),
src_leg (datatype is varchar(128)),
dst_leg (datatype is varchar(128)),
sig_ip (datatype is varchar(128)),
billing_model.(datatype is int(2))
WE WANT TO RUN THE FOLL QUERY ON ACC TABLE :
SELECT t1.sig_ip as src,t1.username as username,t1.fromtag as fromtag,t1.totag as totag,t1.timestamp as calltime,t1.to_uri as destinationnumber,t1.o_uri as o_uri,time_to_sec(timediff(t2.time, t1.time)) as duration FROM acc t1, acc t2
WHERE t1.sip_callid = t2.sip_callid AND ((t1.fromtag = t2.fromtag and t1.totag = t2.totag) OR (t1.fromtag = t2.totag and t1.totag = t2.fromtag)) AND t1.sip_method='INVITE' AND t2.sip_method='BYE';
EXPLAIN select gives:
id is 1, select_type is 'SIMPLE', table is 't1', type is 'ALL', possible_keys is 'sip_callid',key iS null, key_len is null,ref is null,rows is '7' extra is 'Using where'.
id is 1, select_type is 'SIMPLE', table is 't2', type is 'ALL', possible_keys is 'sip_callid',key iS null, key_len is null,ref is null,rows is '7' extra is 'Using where'.
the storage engine is MyISAM
SUGGEST WAYS WE CAN OPTIMIZE THIS QUERY SO THAT OUR QUERING N PROCESSING TIME IS REDUCED AS WE RUN THIS QUERY ON ACC TABLE WHICH HAS LAKHS OF ENTRIES. WE HAVENT USED INDEXING COZ IT WOULD INCREASE OUR INSERTING TIME IN THE ACC TABLE AS WE HAVE TO INSERT LAKHS OF ENTRIES...CORRECT US IF WE ARE WRONG...
WAITING EAGERLY FOR YOUR SUGGESTIONS...
thank you.