waza-ari / monolog-mysql

MySQL Handler for Monolog, which allows to store log messages to a MySQL Table
MIT License
141 stars 85 forks source link

Create indexes #9

Closed claudio-silva closed 7 years ago

claudio-silva commented 9 years ago

If we want to sort on the time field, or filter by channel or level, and the log table has many records, it could take a looong time... Also, if one needs to periodically truncate the log (for instance, discarding entries older than a given treshold) it would be slow. You should add indexes to those fields. You may also give the option of creating them if one needs them, for those people that, for some reason, may not want them.

selabie68 commented 9 years ago

+1 on this. Would be nice to have as an option at least (not on by default but a variable) In case we want to option of archiving or deleting single rows.

waza-ari commented 8 years ago

Definitely a good point, going to look at this soon. I'd propose to add an auto incremental primary key id as a new column, and also add a btree index on the time column as well as a hash index on the channel. Any other suggestions?

claudio-silva commented 8 years ago

The level is also important (for ex, retrieve only warnings or above).

clement-garrigou commented 7 years ago

Is there any news about this feature ?

waza-ari commented 7 years ago

I see that this is a very useful and reasonable feature. In the mean time I was busy with other things and I can't promise at which point I will find time to implement this. If you want, please feel free to implement it and create a pull request. Otherwise, I guess it will be probably somewhere next year.

clement-garrigou commented 7 years ago

Ok I will create a pull request soon : Id : primary key time : btree index channel : hash index level : hash index Is it OK ? Any other suggestions ?