summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorJoseph Fernandes <josferna@redhat.com>2016-03-04 08:55:09 +0530
committerDan Lambright <dlambrig@redhat.com>2016-04-26 14:51:05 -0700
commit681d4590bd7e13b742c399573da55c509eb5b2a2 (patch)
treebfd0e4a6bca4d0eb9081fc64356bc2aefb695a71 /libglusterfs
parent034c986b9b665714aca09e5422bef24466604115 (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. Backport of http://review.gluster.org/13607 > 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> Signed-off-by: Joseph Fernandes <josferna@redhat.com> Change-Id: If5fad07f8d0f50016b10e256803abd5266cd708f BUG: 1323017 Reviewed-on: http://review.gluster.org/13881 Smoke: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Joseph Fernandes 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')
-rw-r--r--libglusterfs/src/gfdb/gfdb_sqlite3.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/libglusterfs/src/gfdb/gfdb_sqlite3.c b/libglusterfs/src/gfdb/gfdb_sqlite3.c
index abd96b7e68d..7e60d133f00 100644
--- a/libglusterfs/src/gfdb/gfdb_sqlite3.c
+++ b/libglusterfs/src/gfdb/gfdb_sqlite3.c
@@ -706,7 +706,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,
@@ -802,7 +806,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,
@@ -909,7 +917,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,
@@ -1055,7 +1068,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*/
@@ -1064,7 +1077,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,