The invention belongs to the technical field of a 
database, and discloses a gray-code-based distributed 
data layout method. The method comprises the steps of: dividing a range of each attribute into a plurality of equal portions; encoding according to a 
gray code order; marking a certain attribute value of a tuple comprising a plurality of attributes through the gray codes of the equal portions of the attribute value, namely an index code of the attribute value; forming an index key value of the tuple by mixing the index code of each attribute value in the tuple, wherein the tuple achieves the distributed 
data layout according to the order of the gray codes, the distributed 
data layout is deployed on a distributed 
system, the 
bitmap index of content 
perception is achieved at a host 
computer terminal of the 
system and the content 
perception is stored in a file name, and physical storage of data and 
statistical index of the data are achieved on a slave terminal of the 
system. The invention also discloses a query method employing the 
database formed by means of the method. The data 
layout obtained by the method can meet the requirements of 
data processing such as 
exact matching search, range search, multi-dimensional search, multi-attribute search and aggregated analysis, and the method is high in disc access efficiency.