diff options
author | Joseph Fernandes <josferna@redhat.com> | 2016-03-04 08:55:09 +0530 |
---|---|---|
committer | Dan Lambright <dlambrig@redhat.com> | 2016-03-29 07:09:33 -0700 |
commit | 916eb46d434097a8e7905ac3be0f0d9a0b4b3da2 (patch) | |
tree | a70f6895fa48d4015aa05a461958ef53a16110f6 /libglusterfs/src | |
parent | 516db811a3bc1b3e778c383fc18aa5eb56342f77 (diff) |
tier/libgfdb: Ordering query results from libgfdb
When querying we will order the query result to get
the hotest or the coldest files in the queried list
so that these files are migrated first.
Now here we are giving priority to the write heat(time and counters),
as it requires complex queries to have a composite
ordering of write and read + it has it impact on performance.
Change-Id: I2e0415dcfad4218b42c68fc5c2ed8d1f075ce9ea
Signed-off-by: Joseph Fernandes <josferna@redhat.com>
Reviewed-on: http://review.gluster.org/13607
Smoke: Gluster Build System <jenkins@build.gluster.com>
Tested-by: Joseph Fernandes
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Dan Lambright <dlambrig@redhat.com>
Diffstat (limited to 'libglusterfs/src')
-rw-r--r-- | libglusterfs/src/gfdb/gfdb_sqlite3.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/libglusterfs/src/gfdb/gfdb_sqlite3.c b/libglusterfs/src/gfdb/gfdb_sqlite3.c index 71d12db72c8..1d10afdaef7 100644 --- a/libglusterfs/src/gfdb/gfdb_sqlite3.c +++ b/libglusterfs/src/gfdb/gfdb_sqlite3.c @@ -707,7 +707,11 @@ gf_sqlite3_find_recently_changed_files(void *db_conn, " OR " /*Second condition: For reads*/ "((" GF_COL_TB_RWSEC " * " TOSTRING(GFDB_MICROSEC) " + " - GF_COL_TB_RWMSEC ") >= ?) )", base_query_str); + GF_COL_TB_RWMSEC ") >= ?) )" + /* Order by write wind time in a descending order + * i.e most hot files w.r.t to write */ + " ORDER BY GF_FILE_TB.W_SEC DESC", + base_query_str); if (ret < 0) { gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_QUERY_FAILED, @@ -803,7 +807,11 @@ gf_sqlite3_find_unchanged_for_time (void *db_conn, " AND " /*Second condition: For reads*/ "((" GF_COL_TB_RWSEC " * " TOSTRING(GFDB_MICROSEC) " + " - GF_COL_TB_RWMSEC ") <= ?) )", base_query_str); + GF_COL_TB_RWMSEC ") <= ?) )" + /* Order by write wind time in a ascending order + * i.e most cold files w.r.t to write */ + " ORDER BY GF_FILE_TB.W_SEC ASC", + base_query_str); if (ret < 0) { gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_QUERY_FAILED, @@ -910,7 +918,12 @@ gf_sqlite3_find_recently_changed_files_freq (void *db_conn, /*Second condition: For Reads */ "( ((" GF_COL_TB_RWSEC " * " TOSTRING(GFDB_MICROSEC) " + " GF_COL_TB_RWMSEC ") >= ?)" - " AND "" (" GF_COL_TB_RFC " >= ? ) ) )", base_query_str); + " AND "" (" GF_COL_TB_RFC " >= ? ) ) )" + /* Order by write wind time and write freq in a descending order + * i.e most hot files w.r.t to write */ + " ORDER BY GF_FILE_TB.W_SEC DESC, " + "GF_FILE_TB.WRITE_FREQ_CNTR DESC", + base_query_str); if (ret < 0) { gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_QUERY_FAILED, @@ -1056,7 +1069,7 @@ gf_sqlite3_find_unchanged_for_time_freq (void *db_conn, GF_COL_TB_WMSEC ") >= ? ) ) )" " AND " /*Second condition: For Reads - * Files that have read wind time smaller than for_time + * Files that have reaASCd wind time smaller than for_time * OR * File that have read wind time greater than for_time, * but write_frequency less than freq_write_cnt*/ @@ -1065,7 +1078,12 @@ gf_sqlite3_find_unchanged_for_time_freq (void *db_conn, " OR " "( (" GF_COL_TB_RFC " < ? ) AND" "((" GF_COL_TB_RWSEC " * " TOSTRING(GFDB_MICROSEC) " + " - GF_COL_TB_RWMSEC ") >= ? ) ) ) )", base_query_str); + GF_COL_TB_RWMSEC ") >= ? ) ) ) )" + /* Order by write wind time and write freq in ascending order + * i.e most cold files w.r.t to write */ + " ORDER BY GF_FILE_TB.W_SEC ASC, " + "GF_FILE_TB.WRITE_FREQ_CNTR ASC", + base_query_str); if (ret < 0) { gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_QUERY_FAILED, |