I create a simple vote, a unique viewer, a unique function count count etc. in php / mysql, and I have one question regarding performance:
Due to the large number of activities on this small system, I want to know what works best for this, using multiple columns INTor 1 single column VARCHAR, of course, in terms of performance:
$uniqueid= STRING generated from system (ip, cookies Etc)
$contentid = INT ID on primary key of content table
$contenttype = INT 0-n ( comment = 0, poll = 1, filedownload = 2 Etc).
$action = INT 0-n ( vote = 0, view = 1, download = 2 Etc)
SELECT *
FROM `table`
WHERE `uid` = '$uniqueid' AND `cid` = '$contentid' AND `ct` = '$contenttype' AND `action` = '$action' ;
Or that:
$key = "$uniqueid-$contentid-$contenttype-$action";
SELECT *
FROM `table`
WHERE `key` = '$key';
source
share