Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-6728

Lazy loading of database tables and schemas

    XMLWordPrintableJSON

Details

    • Wish
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.38.0
    • None
    • core

    Description

      We are facing the issue that our Database contains 500000 schemas with up to 500000 tables each.

      Caching all these schemas and tables is not an option
      1. It will require a lot of memory
      2. The eviction of the cache must happen quite often since it's likely that every second one of these table is changed.

      We worked around this issue by introducing some kind of lazy loading. We did this in the following way:

      Instead of having pairs of methods to lookup tables and schemas (e.g. getTable and getTableNames), we introduced a new Lookup interface, which bundles these two methods

      public interface Lookup<T> {
        /**
         * Returns an entity with a given name, or null if not found.
         * The name is matched case sensitive.
         *
         * @param name Name
         * @return Entity, or null
         */
        @Nullable  T get(String name) ;
      
        /**
         * Returns a named entity with a given name ignoring the case, or null if not found.
         *
         * @param name Name
         * @return Entity, or null
         */
        @Nullable Named<T> getIgnoreCase(String name) ;
      
        /**
         * Returns the names of the entities in matching pattern.
         *
         * @return Names of the entities
         */
        Set<String> getNames(LikePattern pattern);
      }
      

      and modified the Schema interface accordingly

      public interface Schema {
      
        /**
         * Returns a lookup object to find tables
         *
         * @return Lookup
         */
        Lookup<Table> tables();
      
        /**
         * Returns a lookup object to find schemas
         *
         * @return Lookup
         */
        Lookup<? extends Schema> subSchemas();
        ...
      }
      

      Most of the changes can be found in this commit.

      With theses changes we have been able to manage the huge amount of schemas and tables.

      Here are my questions related to my wish/proposal:

      • Does it make sense to provide a PR wich includes these modifications although they might break compatibility with older versions?
      • Does someone else have a great idea to introduce lazy loading with a smaller change?

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              kramerul Ulrich Kramer
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: