A computer-implemented method for storing and querying time series data, comprising: upon receiving data to be stored from an Internet of things, IoT, device, determining a data type of the data to be stored, wherein the data to be stored is time series data, and the data type is intended to indicate a change in the time series data over time; obtaining compressed data by compressing the data to be stored by a data compression method corresponding to the data type, wherein different data types correspond to different data compression methods; storing the compressed data to a data storage table corresponding to the data type, wherein different data types correspond to different data storage tables; receiving a query request, wherein the query request comprises a query data type and a query time condition; and querying target data that meets the query time condition from a data storage table corresponding to the query data type; wherein the data to be stored comprises a state quantity, wherein the state quantity is a physical quantity that is discontinuous over time and has a value belonging to a preset enumerated data set, and obtaining the compressed data by compressing the data to be stored by the data compression method corresponding to the data type comprises: reading values of n pieces of state quantity that are continuously received, wherein n is an integer greater than or equal to 2; and obtaining the compressed data by compressing the n pieces of state quantity based on changes in the values of the n pieces of state quantity. upon receiving data to be stored from an Internet of things, IoT, device, determining a data type of the data to be stored, wherein the data to be stored is time series data, and the data type is intended to indicate a change in the time series data over time; obtaining compressed data by compressing the data to be stored by a data compression method corresponding to the data type, wherein different data types correspond to different data compression methods; storing the compressed data to a data storage table corresponding to the data type, wherein different data types correspond to different data storage tables; receiving a query request, wherein the query request comprises a query data type and a query time condition; and querying target data that meets the query time condition from a data storage table corresponding to the query data type; wherein the data to be stored comprises a state quantity, wherein the state quantity is a physical quantity that is discontinuous over time and has a value belonging to a preset enumerated data set, and obtaining the compressed data by compressing the data to be stored by the data compression method corresponding to the data type comprises: reading values of n pieces of state quantity that are continuously received, wherein n is an integer greater than or equal to 2; and obtaining the compressed data by compressing the n pieces of state quantity based on changes in the values of the n pieces of state quantity. reading values of n pieces of state quantity that are continuously received, wherein n is an integer greater than or equal to 2; and obtaining the compressed data by compressing the n pieces of state quantity based on changes in the values of the n pieces of state quantity. <EOS>