Certain types of applications need to create database tables with multi-column keys. System background jobs, such as tools for replication, migration, deletion, sweepers, and the like, may need to scan the entire table. Scanning the table, one tenant identifier at a time, requires a large number of queries with unpredictable size of results. Full table scans can be performed, but they typically take a long time to perform, and utilize a lot of database system resources. Indexes can be built on one or more columns of the table, where each column in the index is ordered and the sort order is specified when the index is created. However, present systems do not provide a query operator to perform bounded multi-column scans on tables or indexed tables.
The accompanying drawings, which are included to provide a further understanding of the disclosed subject matter, are incorporated in and constitute a part of this specification. The drawings also illustrate implementations of the disclosed subject matter and together with the detailed description serve to explain the principles of implementations of the disclosed subject matter. No attempt is made to show structural details in more detail than may be necessary for a fundamental understanding of the disclosed subject matter and various ways in which it may be practiced.
Indexes for a database may be built on one or more columns of a database table. Each column in the index may be ordered, and the sort order may be determined when the index is created. The index may be maintained by operations (e.g., Data Manipulation Language (DML) operations, or other operations such as insert, update, delete, or the like) on the table.
When performing queries on the table, the index may be used to improve performance. Indexes may provide increased efficiency in row lookup operations, such as in a unique scan), and/or in performing simple scans, such as single column scans, scans of a particular range, or the like.
Implementations of the disclosed subject matter provide a scan range operator for a database query language that allows for data to be accessed using an indexed database. When used in a query, the database system may scan the index, starting at the lower bound column values and end at the upper bound column values, and return the resulting rows in that range. Implementations of the disclosed subject matter translate queries with the scan range operator to standard queries (e.g., SQL queries). That is, implementations of the disclosed subject matter break a query into multiple smaller index scans connected by, for example, a UNION ALL set operation.
The implementations of the disclosed subject matter provide advantages over present database systems and methods by reducing the complexity of a query, and allowing application developers to reduce their focus on the number and/or ordering of the one or more columns of a table in a database. Although system resources may be used in translating the query, the reduction of the complexity of the query more efficiently utilizes system resources, when compared to present systems.
Implementations of the disclosed subject matter can reduce the complexity of queries using standard operators by using a scan range operator. The complexity of the query may increase proportionally to the number of scan columns.
Implementations of the disclosed subject matter may return all the rows with column values between lower bound and upper bound. In some implementations, the lower bound and upper bound may be predefined. If upper bound column values are before lower bound values, then no rows are returned. If lower bound column values are NULL, all rows from the beginning (unbounded) of the index are returned. If upper bound column values are NULL, all rows until the end (unbounded) of the index are returned.
Implementations of the disclosed subject matter may be used for full table scans or partial table scans. The portion of the table scanned may be application dependent. For most applications, unless a full table scan is needed, the systems and methods of the disclosed subject matter may be used for partial table scans to minimize the use of system resources and increase system efficiency.
The tenant data (e.g., stored in the storage 1260 in
In operation 11 of
In operation 12, the scan range operation of the received first query for data in the indexed table may include at least one of a full scan of the indexed table, a partial scan of the indexed data, or the like. The first query may be from, for example, computer 600 or central component 700 shown in
At operation 14, central component 700 shown in
At operation 16 of
In some implementations, the scan range may have a lower bound and an upper bound, and the method 10 may include returning zero rows, or one or more rows with column values between the lower bound and the upper bound. In some implementations, the method 10 may return no rows when column values of the upper bound are before the lower bound values. One or more rows may be returned from the beginning of the index in some implementations when column values of the lower bound are null. In some implementations, when column values of the upper bound are null, the method 10 may return zero rows or one or more rows until the end of the index are returned.
The method 10 described above and in implementations disclosed throughout may be performed on a table in a database having records. A record may be identified by a key-value pair in the instance of a multitenant system. In the implementations discussed throughout, the databases may not have notions of tenancy. Tenancy in the databases may be created by one or more virtual overlays, so that a user may view, access, and/or perform operations for a tenancy associated with an authorized user of a database system. The value may be, for example, the contents of a row of a table of a relational database, an identification of a row in a table of a relational database, or any other suitable value. The key may be an identifier for the record, and may in any suitable form, such as, for example, an alphanumeric sequence. Portions of the key may provide information about the contents of the record. For example, a portion of the key may be a tenant identifier, which may uniquely identify the tenant to whom the contents of the record belongs. Other portions of the key may identify, for example, a table number and identification of a row, for example, when the value of a record is the contents of a row, or table number, index number on the table, and an identification of indexed columns when the value is the identification of a row.
The database system (e.g., system 30 shown in
Time stamps or other time identifiers may be made at the creation of a tenant. Thereafter, tenant data may interpret primary key requests for versions of the data before the time stamp by accessing the appropriate version based on the key in the pool of the data stored before the time stamp. Keys for the respective tenants accessing data created or updated after the time stamp will be interpreted to access the appropriate data created by the tenant. Alternatively, rather than using time stamps, each transaction in the database may have a unique transaction number associated with it that is monotonically increasing for each subsequent transaction and the system may note the most recently created transaction identifier in lieu of the time stamp.
An extent reference may include an extent identifier, a minimum key, a maximum key, an original tenant identifier, a new tenant identifier, and a filter. An extent reference may include an extent identifier (ExtentId), which may be the physical extent to which this points. A minimum key of an extent reference may be minimum key value that the extent reference can access. The minimum key may be the minimum key in the extent. The maximum key of an extent reference may be the maximum key value that the extent reference can access. The filter may be the maximum value of a commit timestamp that indicates when the record came into existence that the extent reference can ‘see’ in this extent.
An extent reference may be used as a logical reference to a physical extent that is stored in physical storage (e.g., a storage device), and the extent references may virtualize access to the immutable storage. For example, as shown in
Certain types of applications (e.g., one or more applications that may be stored and/or executed from applications 1210) may need to create database tables with multi-column keys. Some examples of such applications are multi-tenant data management applications that have tables with two columns for primary keys, one column for a tenant identifier and one column for a row identifier. Metadata based platforms that provide a mechanism to customize objects or create new objects have two columns for primary keys, one column for an object type identifier and one column for an object identifier.
During the typical operations of these applications, all but one of the columns have constant values. In general, the set of columns that have constant values is the tenant identifier. For example, in a multi-tenant application, all operations will happen in the context of a tenant, and will have a tenant identifier predicate. In metadata based platforms, all operations will happen in the context of an object type, and will have an object type identifier predicate. In this example, the object type identifier is the tenant identifier.
The system and methods of the disclosed subject matter, such as method 10 described above in connection with
In another example, scanning the table one tenant identifier at a time may require performing a large number of queries with unpredictable size of results.
Alternatively, full table scans can be performed.
To address the problems shown in
Systems and methods of the disclosed subject matter may create sorted multi-column indexes on tables. These indexes may be used to improve performance of queries on the tables. System and methods of the disclosed subject matter may also provide an operator (e.g., SCAN RANGE, as discussed throughout) to perform bounded multi-column scans of keys.
Indexes of a database may be built on one or more columns of the table. Each column in the index may be ordered, and the sort order is specified when the index is created. The index may maintained by operations (e.g., insert, update, delete, and the like) on the table.
When performing operations in response to a query on the table, the index may be used to improve performance of the database system (e.g., to more efficiently retrieve information related to the query). Indexes, and the systems and methods disclosed herein, may increase the efficiency row lookup operations (e.g., a unique scan), and may perform scans (e.g., single column scans, a scan of a particular range, or the like).
The systems and methods disclosed herein (e.g., method 10 described above in shown in
The following is an example syntax for the SCAN RANGE operator which allows for data to be accessed using an index:
SCAN (sort_specification_list) RANGE [INCLUSIVE/EXCLUSIVE]
(lower_bound_column_values) TO [INCLUSIVE/EXCLUSIVE]
(upper_bound_column_values
Table 1 below describes the elements of the example syntax:
As described in detail above in connection with
The following example may show the creation of a table and an index for the table using the systems (e.g., system 30 shown in
The following example may show the creation of an index for the table:
The syntax above may create a table for a particular user, where the table has entries for OrgID, Username, Team, StartDate, and Enddate. The indexing indicated that the OrgID, Username, and Team have indices that ascend (i.e., “ASC”), and that Role has indices that descend (i.e., “DESC”).
With the created table, a query to select rows between the lower bound and upper bound as inclusive may have the following syntax:
The syntax example above sets an inclusive scan range from the lower bound entry having a Username of alice@abc.com, a Role of 03-LMTS, and a Team of IOT to the upper bound entry of a Username of claudia@abc.com, a Role of 05-Architect, and a Team of IOT.
Systems and methods of the disclosed subject matter may translate SCAN RANGE queries into standard database queries (e.g., SQL queries or the like) while minimizing efficiency loss. In some implementations, the resulting query may be composed of sub-queries joined by a UNION ALL operation or by any other suitable connection operation.
As an example, the following syntax may set a lower bound inclusive term, and may select up to one row. This may be used, for example, only when lower bound is not NULL and is INCLUSIVE. The lower bound inclusive term is shown in
A lower bound term may include the following sub-queries joined by a UNION ALL operation or other suitable operation. This may be used, for example, only when the lower bound is not NULL. The lower bound term is shown in
a. N-th term sub-query:
b. N−1 th term sub-query:
d. 2nd term sub-query:
An inner term query may be illustrated in the below example query. The inner term query is shown in
AFTER(col_name[1], lower_bound_value[1])
AND BEFORE(col_name[1], lower_bound_value[1])
An upper bound term may include the following sub-queries joined by a UNION ALL operation. This may be used, for example, only when the upper bound is not NULL. The upper bound term is shown in
a. 2nd term sub-query:
b. N−1 th term sub-query:
c.
d. N-th term sub-query:
An upper bound inclusive term may select up to one row, as shown in the example query below. This may be used, for example, only when the upper bound is not NULL and inclusive. The upper bound inclusive term is shown in
col_name [1]=upper_bound_value [1]
AND_col_name[2]=upper_bound_value [2] AND . . .
AND_col_name [N]=upper_bound_value [N]
The queries above may have the following conditions:
EQUALS (col, value): col is equal to value
AFTER (col, value): col is after value in sort_specification_list order
BEFORE (col, value): col is before value in sort_specification_list order
Table 2 below shows an example comparison of the queries on a database table with a three column scan that selects the same set of rows. In the first column, “Using SCAN operator,” the query may use the SCAN RANGE operator of the disclosed subject matter. In the second column, “Using Standard Operator,” the query may use standard database operators (e.g., standard SQL operators or the like). The complexity of the query using standard operators is significantly more than that using the SCAN RANGE operator with the systems and methods disclosed herein. The complexity of the query may increase proportionally to the number of scan columns.
The systems and methods disclosed herein may be used for an audit feature, where a user may need to walk through all the data. In some implementations, the data may be stored in one database table with a two column index (e.g., BusinessObjectType and BusniessObjectld). Using the above-described methods, a scan may be performed of the index using the SCAN RANGE operator to create milestones. Using these milestones as the LOWER BOUND and UPPER BOUND for the SCAN RANGE operator, the table may be scanned to process the rows, as shown in
An access layer 32 of the system 30 may have a database storage engine 33, which may receive or complete a query and/or instruction for the database system (e.g., central component 700 shown in
The system 30 may include a virtualization layer 34, which may have an extent reference 35. In some implementations, the extent reference 35 may be part of the central component 700 shown in
Implementations of the presently disclosed subject matter may be implemented in and used with a variety of component and network architectures.
Data may be stored in any suitable format in, for example, the storage 810, using any suitable filesystem or storage scheme or hierarchy. For example, the storage 810 may store data using a table and/or a log structured merge (LSM) tree with multiple levels. Further, if the systems shown in
The information obtained to and/or from a central component 700 may be isolated for each computer such that computer 600 may not share information with computer 800. Alternatively or in addition, computer 600 may communicate directly with the second computer 800.
The computer (e.g., user computer, enterprise computer, etc.) 600 includes a bus 610 which interconnects major components of the computer 600, such as a central processor 640, a memory 670 (typically RAM, but which may also include ROM, flash RAM, or the like), an input/output controller 680, a user display 620, such as a display or touch screen via a display adapter, a user input interface 660, which may include one or more controllers and associated user input or devices such as a keyboard, mouse, WiFi/cellular radios, touchscreen, microphone/speakers and the like, and may be closely coupled to the I/O controller 680, fixed storage 630, such as a hard drive, flash storage, Fibre Channel network, SAN device, SCSI device, and the like, and a removable media component 650 operative to control and receive an optical disk, flash drive, and the like.
The bus 610 enable data communication between the central processor 640 and the memory 670, which may include read-only memory (ROM) or flash memory (neither shown), and random access memory (RAM) (not shown), as previously noted. The RAM can include the main memory into which the operating system and application programs are loaded. The ROM or flash memory can contain, among other code, the Basic Input-Output system (BIOS) which controls basic hardware operation such as the interaction with peripheral components. Applications resident with the computer 600 can be stored on and accessed via a computer readable medium, such as a hard disk drive (e.g., fixed storage 630), an optical drive, floppy disk, or other storage medium 650.
The fixed storage 630 may be integral with the computer 600 or may be separate and accessed through other interfaces. The fixed storage 630 may be part of a storage area network (SAN). A network interface 690 may provide a direct connection to a remote server via a telephone link, to the Internet via an internet service provider (ISP), or a direct connection to a remote server via a direct network link to the Internet via a POP (point of presence) or other technique. The network interface 690 may provide such connection using wireless techniques, including digital cellular telephone connection, Cellular Digital Packet Data (CDPD) connection, digital satellite data connection or the like. For example, the network interface 690 may enable the computer to communicate with other computers and/or storage devices via one or more local, wide-area, or other networks, as shown in
Many other devices or components (not shown) may be connected in a similar manner (e.g., data cache systems, application servers, communication network switches, firewall devices, authentication and/or authorization servers, computer and/or network security systems, and the like). Conversely, all of the components shown in
One or more of the database systems 1200a-1200d may receive a query and perform a full table scan and/or one or more scan ranges for tenant data in a table. The database systems 1200a-1200d may include at least one storage device, such as storage 1260 shown in
Tenant data may be stored in an immutable storage (e.g., storage 1260 of
The one or more servers of the systems shown in
The tenant data may be associated with a metadata tenant identifier and metadata that is indicative of when records are created and deleted from the database system, and is indicative of different versions of tenant data that are committed to the database system from time-to-time. At least one server (e.g., computer 600, central component 700, second computer 800, and/or the storage 1260 of the database systems 1200a-1200d) may locate metadata to identify the data of a tenant stored in the storage device.
The system 30 shown in
The server system may receive a first query for data in the indexed table, where the query includes a scan range. The server system may translate the first query that includes the scan range into a plurality of sub-queries having respective scan ranges. That is, the server system may translate the first query into the plurality of sub-queries having respective scan ranges to reduce the complexity of the first query. The scan range may have a lower bound and an upper bound, and the server system may return zero rows or one or more rows with column values between the lower bound and the upper bound. In some implementations, the server system may return no rows when column values of the upper bound are before the lower bound values. In some implementations, the server system may return zero rows, or one or more rows from the beginning of the index when column values of the lower bound are null. In some implementations, the server system may return zero rows, or one or more rows until the end of the index are returned when column values of the upper bound are null.
In some implementations, the scan range of the received first query for data in the indexed table may include a full scan of the indexed table and/or a partial scan of the indexed data. IN some implementations, the scan range of the received first query for data in the indexed table is based on an application that provides the query to the server system. The lower bound and/or the upper bound may be an inclusive bound and/or an exclusive bound.
The server system may form a second query by combining the sub-queries with an operation, process the formed second query, and output a result of the second query. The server system combines the sub-queries by using a union all operation.
The systems and methods of the disclosed subject matter may be for single tenancy and/or multitenancy systems. Multitenancy systems may allow various tenants, which may be, for example, users, groups of users, or organizations, to access their own records on the server system through software tools or instances on the server system that may be shared among the various tenants. The contents of records for each tenant may be part of a database containing that tenant. Contents of records for multiple tenants may all be stored together within the same database system, but each tenant may only be able to access contents of records which belong to, or were created by, that tenant. This may allow a database system to enable multitenancy without having to store each tenants' contents of records separately, for example, on separate servers or server systems. The database for a tenant may be, for example, a relational database, hierarchical database, or any other suitable database type. All records and/or tables stored on the server system may be stored in any suitable structure, including, for example, a LSM tree.
A multitenant system may have various tenant instances on server systems distributed throughout a network with a computing system at each node. The live or production database instance of each tenant may only have its transactions processed at one computer system. The computing system for processing the transactions of that instance may also process transactions of other instances for other tenants. The computing system may store at least one table of a database that includes tenant data.
More generally, various implementations of the presently disclosed subject matter may include or be implemented in the form of computer-implemented processes and apparatuses for practicing those processes. Implementations also may be implemented in the form of a computer program product having computer program code containing instructions implemented in non-transitory and/or tangible media, such as floppy diskettes, CD-ROMs, hard drives, USB (universal serial bus) drives, or any other machine readable storage medium, wherein, when the computer program code is loaded into and executed by a computer, the computer becomes an apparatus for practicing implementations of the disclosed subject matter. Implementations also may be implemented in the form of computer program code, for example, whether stored in a storage medium, loaded into and/or executed by a computer, or transmitted over some transmission medium, such as over electrical wiring or cabling, through fiber optics, or via electromagnetic radiation, wherein when the computer program code is loaded into and executed by a computer, the computer becomes an apparatus for practicing implementations of the disclosed subject matter. When implemented on a general-purpose microprocessor, the computer program code segments configure the microprocessor to create specific logic circuits. In some configurations, a set of computer-readable instructions stored on a computer-readable storage medium may be implemented by a general-purpose processor, which may transform the general-purpose processor or a device containing the general-purpose processor into a special-purpose device configured to implement or carry out the instructions. Implementations may be implemented using hardware that may include a processor, such as a general purpose microprocessor and/or an Application Specific Integrated Circuit (ASIC) that implements all or part of the techniques according to implementations of the disclosed subject matter in hardware and/or firmware. The processor may be coupled to memory, such as RAM, ROM, flash memory, a hard disk or any other device capable of storing electronic information. The memory may store instructions adapted to be executed by the processor to perform the techniques according to implementations of the disclosed subject matter.
The foregoing description, for purpose of explanation, has been described with reference to specific implementations. However, the illustrative discussions above are not intended to be exhaustive or to limit implementations of the disclosed subject matter to the precise forms disclosed. Many modifications and variations are possible in view of the above teachings. The implementations were chosen and described in order to explain the principles of implementations of the disclosed subject matter and their practical applications, to thereby enable others skilled in the art to utilize those implementations as well as various implementations with various modifications as may be suited to the particular use contemplated.