We study the question of when we can answer a Conjunctive Query (CQ) with an ordering over the answers by constructing a structure for direct (random) access to the sorted list of answers, without actually materializing this list, so that the construction time is linear (or quasilinear) in the size of the database. In the absence of answer ordering, such a construction has been devised for the task of enumerating query answers of free-connex acyclic CQs, so that the access time is logarithmic. Moreover, it follows from past results that within the class of CQs without self-joins, being free-connex acyclic is necessary for the existence of such a construction (under conventional assumptions in fine-grained complexity). In this work, we embark on the challenge of identifying the answer orderings that allow for ranked direct access with the above complexity guarantees. We begin with the class of lexicographic orderings and give a decidable characterization of the class of feasible such orderings for every CQ without self-joins. We then continue to the more general case of orderings by the sum of attribute scores. As it turns out, in this case ranked direct access is feasible only in trivial cases. Hence, to better understand the computational challenge at hand, we consider the more modest task of providing access to only one single answer (i.e., finding the answer at a given position). We indeed achieve a quasilinear-time algorithm for a subset of the class of full CQs without self-joins, by adopting a solution of Frederickson and Johnson to the classic problem of selection over sorted matrices. We further prove that none of the other queries in this class admit such an algorithm.
翻译:我们研究一个问题,即我们何时可以对一个CQuery(CQ)做出回答,通过建立直接(随机)访问分解的答案列表的结构来对答案进行排序,而不必实际实现这个列表,这样,建设时间在数据库的大小中是线性(或准线性)的。在没有回答命令的情况下,设计了这样一个构造,以完成对自由计算周期 CQ(CQ)的查询回答,从而访问时间是逻辑性的。此外,根据过去的结果,在没有自我joins的CQ类内部,自由计算周期性对于这种构建的存在是必要的(根据常规假设在精密的复杂度中,建设时间是线性(或准线性 ) 。 在这项工作中,我们开始一项挑战是确定答案,以便根据上述复杂度进行直接访问。我们从分类的类别开始,对每个CQ没有自我joins的可操作性排序的类别作出一个适度的描述。然后我们继续从更普通的排序角度来做一个更精确的解算,我们只能用一个更普通的排序的解算。