Improve SQL query in LEMONdB._star_pfilters and pfilters methods

The current implementation of the inner join (PHOTOMETRY, IMAGES and
PHOTOMETRIC_FILTERS tables) extracts the wavelengths of all of the
rows in the first table, PHOTOMETRY, and then filters out duplicates
with the DISTINCT clause. However, since what we need to identify are
nothing more than the rows in IMAGES for which there is a matching row
in PHOTOMETRY, the number of records that are combined can be reduced
considerably if we use a subquery to extract the distinct IDs of the
images in PHOTOMETRY before proceeding with the first inner join.
Add LEMONdB.analyze method

The ANALYZE command gathers statistics about tables and indexes and
stores the collected information in internal tables of the database
where the query optimizer can access and use it to help make better
query planning choices. The current transaction is committed and a
new one automatically started when the commands finishes.

The statistics gathered by ANALYZE are not automatically updated as
the content of the database changes. If the content of the LEMONdB
changes significantly, we should consider rerunning the command in
order to update the statistics.

SQL As Understood By SQLite: ANALYZE
https://www.sqlite.org/lang_analyze.html
Run ANALYZE on output LEMONdB
Update statistics (re-run ANALYZE) of output LEMONdB
Move the CREATE INDEX commands after the corresponding tables
Remove redundant indexes

The two-column index IMAGES(wavelength, unix_time) makes unnecessary
the existence of the other one, IMAGES(wavelength): the left-most
column is the primary key used for ordering the rows in the index, and
the right-most used to break ties, if any. There is no need of keeping
the single-column index when the two-colum one allows for identical
functionality. The same applies to the PERIODS(star_id, wavelength)
and PERIODS(star_id) indexes — we can get rid of the latter.
Rename index cstars_by_star_and_wavelength
Rename index phot_by_image_id
Replace phot_by_star with a two-column index (star_id, image_id)

A new index, PHOTOMETRY(star_id, image_id), is needed to speed up the
query in the LEMONdB.get_photometry method. This addition means that
PHOTOMETRY(star_id) can be removed: they both start with the same
column, so queries that would use the single-column index can also use
the two-column one — it is not necessary for every column of an index
to appear in a WHERE clause term in order for that index to be used.
Add INDEXED BY clauses to the query in LEMONdB.get_photometry

The INDEXED BY clause specifies the index that must be used in order
to look up values on the preceding table. If the index does not exist
or cannot be used for the query, then the preparation of the statement
fails. Add it to the query in LEMONdB.get_photometry to guarantee that
the phot_by_star_image and img_by_wavelength_time indexes are used.

This clause, an SQL extension found only in SQLite, is not intended
for use in tuning the performance of a SQL query, but to raise a
run-time error if a schema change, such as dropping or creating an
index, causes the query plan for a time-sensitive query to change.

SQL As Understood By SQLite: INDEXED BY
https://www.sqlite.org/lang_indexedby.html
Add INDEXED BY clause to LEMONdB._star_pfilters
Add INDEXED BY clause to LEMONdB.pfilters
Add INDEXED BY clause to LEMONdB.get_period and get_periods
Replace curve_by_star with a two-column index (star_id, image_id)

The LIGHT_CURVES(star_id, image_id) index is necessary to speed up the
first of the two SQL queries in LEMONdB.get_light_curve. As was done
in commit 6a3150d2f6f4d, this means that index LIGHT_CURVES(star_id),
which starts with the same row, becomes redundant and can be removed.
Add INDEXED BY clauses to LEMONdB.get_light_curve
Add INDEXED BY clause to LEMONdB._get_image_id
Add INDEXED BY clause to LEMONdB.airmasses
Add three-column index phot_params_all_rows

This index contains all of the columns of the PHOTOMETRIC_PARAMETERS
table (aperture, annulus, dannulus) and, as such, is a covering index
for all the possible queries on this table (as it can satisfy all the
requested columns without having to consult the table).
Add INDEXED BY clause to LEMONdB._add_pparams
Add single-column index cand_wavelength

Although the CANDIDATE_PARAMETERS table is not expected to contain, in
any foreseeable future, more than, at most, a few hundreds records, a
full-table scan in LEMONdB.get_candidate_pparams can be avoided with
an index on the wavelength column.