lesterchan / wp-polls

Adds an AJAX poll system to your WordPress blog. You can also easily add a poll into your WordPress's blog post/page.
https://wordpress.org/plugins/wp-polls/
93 stars 78 forks source link

Wrong column datatypes? #85

Closed dmarkic closed 7 years ago

dmarkic commented 7 years ago

Hello,

is there any special reason why columns pollip_qid and pollip_aid in pollsip table are VARCHAR and not INT? Also pollip_timestamp is VARCHAR which is rather strange. Also in pollsq table you have pollq_expiry which seems to be timestamp, stored as varchar.

Could you update those, as you're using ints in your code and indexes don't work if you do polla_qid = 10 and polla_qid is VARCHAR as it needs to convert the value being searched.

Best regards, Dejan

lesterchan commented 7 years ago

Thanks for the feedback. I will change it to int(10). Unlikely I will touch timestamp as VARCHAR seems ok. If I change it to TIMESTAMP, It will break a lot of stuff.

dmarkic commented 7 years ago

Hello, well, timestamp could be unsigned int - that's 4 bytes. VARCHAR(10) takes 11 bytes (on utf8 3-4 times more), so as much as 41 bytes. That's a huge difference.

lesterchan commented 7 years ago

I see. So should int(10) works better or bigint(20) just in case?

dmarkic commented 7 years ago

int(10) is enough: https://dev.mysql.com/doc/refman/5.7/en/integer-types.html