
--explain
select
	ri.remoteip,
	hn.hostname,
	pa.path,
	qu.query
from
	httplog h,
	referer rf,
	hostname hn,
	path pa,
	query qu,
	remoteip ri
where 
	rf.queryid = qu.queryid
	and h.remoteipid = ri.remoteipid
	and h.refererid = rf.refererid
	and rf.hostnameid = hn.hostnameid
	and rf.pathid = pa.pathid
	and query ~ '\\\?id=[0-9]+'
	and hostname ~ 'forbrug.dk'
;

--
select count(*), min(hitDateTime), max(hitDateTime) from httplog where hostid in (select hostnameid from hostname where hostname ~ 'forbrug.dk');
