Introspection levels
Database users might experience a long introspection time if there are lots of objects (tables, schemas, databases, and so on). Introspection is the process of getting the metadata of the database, such as object names, types of columns, and source code. PyCharm uses this information to provide coding assistance, navigation, and search.
For some databases, system catalogs are relatively slow, and the introspection is even slower if a user has no permissions for accessing fast catalogs.
Usually, for daily work and coding assistance, there is no need to load sources of all the objects. In many cases, having database names will be enough for proper code completion and navigation. PyCharm has the following introspection levels:
Level | Level set manually | Level inherited | Description |
---|---|---|---|
Level 1 | Names of all supported objects and their signatures, except for names of index columns and names of private package variables. | ||
Level 2 | Everything except source code. For example, on this level, if you open a routine, you will see its declaration but not its body. | ||
Level 3 | Everything. |
Icons represent the introspection level: the more the pill is filled, the higher the level. Also, color matters: a blue icon means that the introspection level is set directly, grey means that it is inherited.
For some databases, a fragmental introspection is also implemented. It is the ability to retrieve metadata for one single object. This helps in situations where the metadata (usually, the source code) is explicitly requested. For example, if you double-click a view, but the introspection level is low, PyCharm requests the source code at the same moment.
Right-click an object and select Refresh.
By default, PyCharm automatically sets the default introspection level for each schema based on the schema type and number of objects. For each schema the introspector counts objects and selects the introspection level using the following thresholds, where N is the number of objects:
Schema | Level 3 | Level 2 | Level 1 |
---|---|---|---|
Current | N <= 1000 | N <= 3000 | Otherwise |
Non-current | Never | N <= 3000 | Otherwise |
System | Never | N <= 100 | Otherwise |
The current schema is the one the session is connected to.
To change the defaults, open the Data Sources and Drivers dialog (CtrlAltShift0S) , navigate to Options | Introspection | Default level, and select the default introspection level for your data source.
note
The lower the level, the faster the introspection.
You can set the introspection level either for the whole database or for a particular schema. Schemas inherit their introspection level from the database, but you can set the level independently for each schema.
For the other database objects, the Introspection Level context submenu displays the current introspection level of the object.
By default, introspection level icons are disabled. You can enable them separately: for schemas and their children (tables, views, routines, and so on).
In the Database tool window (View | Tool Windows | Database), click the Show Options Menu icon () and select Introspection Level Icons.
Right-click an object in the Database tool window (View | Tool Windows | Database) and select the Introspection Level menu.
In the Introspection Level menu, select a level you want to apply.
Children inherit a level that is set for a parent.
Note that if you have the Auto sync option enabled in data source settings, the introspection will run as soon as you change the introspection level. For more information about Auto sync, refer to Auto sync in the Data Source and Drivers dialog.
Thanks for your feedback!