yuqi1129 commented on code in PR #9430:
URL: https://github.com/apache/gravitino/pull/9430#discussion_r2670595323


##########
core/src/main/java/org/apache/gravitino/storage/relational/service/FilesetMetaService.java:
##########
@@ -125,15 +119,37 @@ public FilesetEntity 
getFilesetByIdentifier(NameIdentifier identifier) {
   public List<FilesetEntity> listFilesetsByNamespace(Namespace namespace) {
     NamespaceUtil.checkFileset(namespace);
 
+    List<FilesetPO> filesetPOs = listFilesetPOs(namespace);
+    return POConverters.fromFilesetPOs(filesetPOs, namespace);
+  }
+
+  private List<FilesetPO> listFilesetPOs(Namespace namespace) {
+    return filesetListFetcher().apply(namespace);
+  }
+
+  private List<FilesetPO> listFilesetPOsBySchemaId(Namespace namespace) {

Review Comment:
   > The second SQL query you provided includes a filtering condition 
fm.fileset_name = 'test'. Is this condition in line with expectations?
   
   This is an oversight. 
   
   The following is the code.
   ```java
    @BeforeAll
     static void init() throws SQLException {
       connection = DriverManager.getConnection(url, user, password);
     }
   
     @Test
     @SuppressWarnings("unused")
     public void test() throws SQLException {
   
       String sql1 =
           "SELECT mm.metalake_id AS metalakeId, cm.catalog_id AS catalogId, 
sm.schema_id AS schemaId, vi.fileset_id AS filesetId, fm.fileset_name AS 
filesetName, fm.type AS type, fm.audit_info AS auditInfo, fm.current_version AS 
currentVersion, fm.last_version AS lastVersion, fm.deleted_at as deletedAt, 
vi.id, vi.metalake_id as version_metalake_id, vi.catalog_id as 
version_catalog_id, vi.schema_id as version_schema_id, vi.fileset_id as 
version_fileset_id, vi.version, vi.fileset_comment, vi.properties, 
vi.storage_location_name, vi.storage_location, vi.deleted_at as 
version_deleted_at FROM metalake_meta mm INNER JOIN catalog_meta cm ON 
mm.metalake_id = cm.metalake_id AND cm.catalog_name = 'fileset_catalog' AND 
cm.deleted_at = 0 LEFT JOIN schema_meta sm ON cm.catalog_id = sm.catalog_id AND 
sm.schema_name = 'schema' AND sm.deleted_at = 0 LEFT JOIN fileset_meta fm ON 
sm.schema_id = fm.schema_id AND fm.deleted_at = 0 LEFT JOIN 
fileset_version_info vi ON fm.fileset_id = vi.fileset_id AND f
 m.current_version = vi.version AND vi.deleted_at = 0 WHERE mm.metalake_name = 
'test' AND mm.deleted_at = 0;";
   
       String sql2 =
           "SELECT fm.fileset_id, fm.fileset_name, fm.metalake_id, 
fm.catalog_id, fm.schema_id,\n"
               + "fm.type, fm.audit_info, fm.current_version, fm.last_version, 
fm.deleted_at, vi.id, vi.metalake_id as version_metalake_id, vi.catalog_id as 
version_catalog_id, vi.schema_id as version_schema_id, vi.fileset_id as 
version_fileset_id, vi.version, vi.fileset_comment, vi.properties, 
vi.storage_location_name, vi.storage_location, vi.deleted_at as 
version_deleted_at\n"
               + "FROM fileset_meta fm INNER JOIN fileset_version_info vi ON 
fm.fileset_id = vi.fileset_id AND fm.current_version = vi.version WHERE 
fm.schema_id = 1824238720785109989 AND fm.deleted_at = 0 AND vi.deleted_at = 
0;";
       for (int i = 0; i < 100; i++) {
         try (PreparedStatement stmt = connection.prepareStatement(sql1)) {
           try (ResultSet rs = stmt.executeQuery()) {
             if (rs.next()) {
               System.out.println(rs.getLong(1)); // prevent JIT 
             }
           }
         }
       }
   
       long now = System.currentTimeMillis();
       for (int i = 0; i < 10000; i++) {
         try (PreparedStatement stmt = connection.prepareStatement(sql1)) {
           try (ResultSet rs = stmt.executeQuery()) {
             if (rs.next()) {
               System.out.println(rs.getLong(1));  // prevent JIT 
             }
           }
         }
       }
   
       System.out.println(
           "Elapsed time for 10000 queries: " + (System.currentTimeMillis() - 
now) + " ms");
     }
   ```
   
   The difference will increase if tested with a remote database or with a 
large dataset. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to