3
Functional requirement
I own devices. Each device roughly has its unique identifier, an IP address, and a type.
I have a routine of pings for every device that has an ip address. This routine is nothing more than a C#executable, which runs every 3 minutes and tries to drip such IP address from the device.
The result of ping i need to store in the database as well as the date of the check (independent of the result of the ping).
Technical Part:
Supposing that my process of ping and bank structuring be ready from the day 01/06/2016, I need to do two things:
- Daily extraction (which is a fed table)
- Real-time extraction (last 24 hours)
Both must return to me the same thing:
- Devices that have been unavailable for more than 24 hours.
- Devices that have been unavailable for more than 7 days.
Unavailable means the device which, when dripping, did not respond to the ping.
Available means the device which, upon being dripped, ping successfully.
What I have today and works very badly:
A table historico_disponibilidade
, with the following structure:
create table historico_disponibilidade (id_dispositivo number, respondeu number, data date);
This table has a large amount of data (today it has 60 million, but the trend is to grow exponentially)
The questions:
- How to achieve such goals without bumping into problems of slowness in queries?
- How to create a table(s) structure that is prepared to receive millions/billions of records within my corporate universe?
I worked on a system where a single table had 40gigas of data (BD Oracle), the Selects on it was as fast as a smaller table, because it used the correct indexes. The structure of this table is good, you did not put the indexes, but if the id_device is the key and you want to get a range of dates there then you will have performance problems. If in your environment you can simulate such a large table in homologation is worth it for you to have the experience of how it worked.
– Ricardo
@Ricardo, where do you think the index should exist? Yes, I need to pick up by a range of dates and one by id_device as well.
– Marllon Nasser
So, in the log tables that I used we only had an index on the date of the record, nothing else, the index is a new table with that column, it takes space, and there are many, many tables. The selects in the log were always run with a date to use the index. In maintenance was run about 10 logs a day, it was not much, I think it will depend on how much space you can have and how many queries you saw want, I think an index on the date would solve in your case. This data will be displayed on screen for user?
– Ricardo