Question

I have a large MySQL Table containing about 15 Million rows of web log data. Depending on the IP, useragent and site_id (different sections on the website) I want to create user sessions. The session delimiter should be 30 minutes. So if a unique user (same IP and useragent) is inactive for 30 minutes or if he visits a different site area (2, 3, or 4) a new session starts.

I found a very good blog entry, that describes the general procedure: http://randyzwitch.com/sessionizing-log-data-sql/ But I can't implement this 1:1 because MySQL doesn't support window functions and I'm not proficient enough with MySQL to figure it out on my own, e.g. with GROUP_CONCAT().

Here is anonymized example data on sqlfiddle: http://www.sqlfiddle.com/#!9/a8b1f/1

It would be really great if you could help me.

I already posted this question on Stack Overflow.

Was it helpful?

Solution

You've provided your own answer - MySQL doesn't have window-functions (AKA analytic functions). My advice to you would be to switch to PostgreSQL for that reason alone.

Also, PostgreSQL supports SET operators, CHECK constraints, GIS, calculated fields (although MariaDB does support these), and CTEs (Common Table Expressions, AKA the WITH clause) - although see Justin Swanhart's answer here.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top