Commit 640d3538 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[3968] Added ASC sorting for indexes by expiration.

parent e7fd02a5
...@@ -265,8 +265,8 @@ ALTER TABLE lease6 ...@@ -265,8 +265,8 @@ ALTER TABLE lease6
# by the expiration time. One of the applications is to retrieve all # by the expiration time. One of the applications is to retrieve all
# expired leases. However, these indexes can be also used to retrieve # expired leases. However, these indexes can be also used to retrieve
# leases in a given state regardless of the expiration time. # leases in a given state regardless of the expiration time.
CREATE INDEX lease4_by_state_expire ON lease4 (state, expire); CREATE INDEX lease4_by_state_expire ON lease4 (state ASC, expire ASC);
CREATE INDEX lease6_by_state_expire ON lease6 (state, expire); CREATE INDEX lease6_by_state_expire ON lease6 (state ASC, expire ASC);
# Create table holding mapping of the lease states to their names. # Create table holding mapping of the lease states to their names.
# This is not used in queries from the DHCP server but rather in # This is not used in queries from the DHCP server but rather in
......
...@@ -28,8 +28,8 @@ ALTER TABLE lease6 ...@@ -28,8 +28,8 @@ ALTER TABLE lease6
# by the expiration time. One of the applications is to retrieve all # by the expiration time. One of the applications is to retrieve all
# expired leases. However, these indexes can be also used to retrieve # expired leases. However, these indexes can be also used to retrieve
# leases in a given state regardless of the expiration time. # leases in a given state regardless of the expiration time.
CREATE INDEX lease4_by_state_expire ON lease4 (state, expire); CREATE INDEX lease4_by_state_expire ON lease4 (state ASC, expire ASC);
CREATE INDEX lease6_by_state_expire ON lease6 (state, expire); CREATE INDEX lease6_by_state_expire ON lease6 (state ASC, expire ASC);
# Create table holding mapping of the lease states to their names. # Create table holding mapping of the lease states to their names.
# This is not used in queries from the DHCP server but rather in # This is not used in queries from the DHCP server but rather in
......
...@@ -143,7 +143,7 @@ TaggedStatement tagged_statements[] = { ...@@ -143,7 +143,7 @@ TaggedStatement tagged_statements[] = {
"state " "state "
"FROM lease4 " "FROM lease4 "
"WHERE state != ? AND expire < ? " "WHERE state != ? AND expire < ? "
"ORDER BY expire " "ORDER BY expire ASC "
"LIMIT ?"}, "LIMIT ?"},
{MySqlLeaseMgr::GET_LEASE6_ADDR, {MySqlLeaseMgr::GET_LEASE6_ADDR,
"SELECT address, duid, valid_lifetime, " "SELECT address, duid, valid_lifetime, "
...@@ -182,7 +182,7 @@ TaggedStatement tagged_statements[] = { ...@@ -182,7 +182,7 @@ TaggedStatement tagged_statements[] = {
"state " "state "
"FROM lease6 " "FROM lease6 "
"WHERE state != ? AND expire < ? " "WHERE state != ? AND expire < ? "
"ORDER BY expire " "ORDER BY expire ASC "
"LIMIT ?"}, "LIMIT ?"},
{MySqlLeaseMgr::GET_VERSION, {MySqlLeaseMgr::GET_VERSION,
"SELECT version, minor FROM schema_version"}, "SELECT version, minor FROM schema_version"},
......
...@@ -220,8 +220,8 @@ const char* create_statement[] = { ...@@ -220,8 +220,8 @@ const char* create_statement[] = {
"ALTER TABLE lease6 " "ALTER TABLE lease6 "
"ADD COLUMN state INT UNSIGNED DEFAULT 0", "ADD COLUMN state INT UNSIGNED DEFAULT 0",
"CREATE INDEX lease4_by_state_expire ON lease4 (state, expire)", "CREATE INDEX lease4_by_state_expire ON lease4 (state ASC, expire ASC)",
"CREATE INDEX lease6_by_state_expire ON lease6 (state, expire)", "CREATE INDEX lease6_by_state_expire ON lease6 (state ASC, expire ASC)",
// Production schema includes the lease_state table and // Production schema includes the lease_state table and
// lease_hwaddr_source tables which map to the values in lease4 // lease_hwaddr_source tables which map to the values in lease4
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment