Sell ​​- Web 2.0 Ranker – 100% Indexed | Handwritten | Social Signals | High DA Tier 2

Embed

HTML:

BBCode:

Link image:

Fiber category vs indexed category

In Benabou's essay Fibered categories and the basics of naive class theory it says (end page 31):An indexed category is just a representation of a fibrous category.& # 39;

  1. It seems that Benabou argues that fiber optic categories formalize the same idea as indexed categories, but are better to manage. I have also found very little literature on indexed categories. Is the concept of the "indexed category" a bit outdated compared to the "fibrous category"? (Personally, I'm not an expert and am temporarily comfortable with indexed categories, but now I was wondering if I should continue to study the fibrous categories for a better understanding.)

  2. Expressly, from nlab I know that of course you can get from one $ mathcal S $-indexed category an over-fibered category $ mathcal S $using the Grothendieck construction. It is also claimed that two of them are equivalent. So, conversely, how can I restore that? $ mathcal S $indexed category from this fiber category over $ mathcal S $?

postgresql – Postgres with seq scan with filter for indexed column + EXISTS for associated table

I have the following query, which takes about 25-35 seconds to execute:

EXPLAIN (analyze, buffers, format text) SELECT booking.*
FROM booking
WHERE booking.reference_number = '9999999999' OR booking.booking_id = '9999999999' OR 
    (
        EXISTS (
            SELECT * FROM booking_customer 
            WHERE booking_customer.booking_id = booking.booking_id AND 
                (booking_customer.email = '9999999999' OR booking_customer.phone = '9999999999') AND 
                booking_customer.deleted = false
        )
    );

The EXPLAIN issue can be found here: https://explain.depesz.com/s/RPNV

As you can see from the chart, the bookings table is searched one after another, even though filtered by indexed columns. reference_number and booking_id, The booking_customer However, the table uses the index scan correctly.

Does it have something to do with it? EXISTS or OR there clauses?

My table structure is as follows:

                              Table "public.booking"
        Column         |           Type           | Collation | Nullable | Default
-----------------------+--------------------------+-----------+----------+---------
 deleted               | boolean                  |           |          |
 booking_id            | character varying        |           | not null |
 reference_number      | character varying        |           |          |
 booking_owner         | character varying        |           |          |
 checkin_date          | timestamp with time zone |           |          |
 checkout_date         | timestamp with time zone |           |          |
 status                | character varying        |           |          |
 hold_till             | timestamp with time zone |           |          |
 version               | integer                  |           | not null |
 comments              | text                     |           |          |
 extra_information     | json                     |           |          |
 cancellation_reason   | character varying        |           |          |
 cancellation_datetime | timestamp with time zone |           |          |
 created_at            | timestamp with time zone |           | not null | now()
 modified_at           | timestamp with time zone |           | not null | now()
Indexes:
    "booking_pkey" PRIMARY KEY, btree (booking_id)
    "ix_booking_reference_number" UNIQUE, btree (reference_number)
    "idx_booking_checkin_date" btree (checkin_date)
    "idx_booking_checkout_date" btree (checkout_date)
    "ix_booking_status" btree (status)
    "trgm_booking_ref_num" gist (reference_number gist_trgm_ops)

And customer table:

                          Table "public.booking_customer"
        Column         |           Type           | Collation | Nullable | Default
-----------------------+--------------------------+-----------+----------+---------
 deleted               | boolean                  |           |          |
 customer_id           | character varying        |           | not null |
 booking_id            | character varying        |           | not null |
 first_name            | character varying        |           |          |
 last_name             | character varying        |           |          |
 gender                | character varying        |           |          |
 age                   | integer                  |           |          |
 nationality           | character varying        |           |          |
 phone                 | character varying        |           |          |
 email                 | character varying        |           |          |
 gst_addr_field1       | character varying        |           |          |
 gst_addr_field2       | character varying        |           |          |
 gst_addr_city         | character varying        |           |          |
 gst_addr_state        | character varying        |           |          |
 gst_addr_country      | character varying        |           |          |
 gst_pincode           | character varying        |           |          |
 legal_name            | character varying        |           |          |
 created_at            | timestamp with time zone |           | not null | now()
 modified_at           | timestamp with time zone |           | not null | now()
Indexes:
    "booking_customer_pkey" PRIMARY KEY, btree (customer_id, booking_id)
    "book_cust_idx" btree (booking_id, customer_id)
    "ix_booking_customer_email" btree (email)
    "ix_booking_customer_phone" btree (phone)
    "trgm_cust_last_name" gist (last_name gist_trgm_ops)

Details about the total records in the table are as follows:

db=> SELECT COUNT(*) FROM booking;
 count
--------
 958092
(1 row)

db=> SELECT COUNT(*) FROM booking_customer;
  count
---------
 2471445
(1 row)

db=> SELECT COUNT(*) FROM booking WHERE reference_number = '9999999999' OR booking_id = '9999999999';
 count
-------
     1
(1 row)

db=> SELECT COUNT(*) FROM booking_customer WHERE (email = '9999999999' OR phone = '9999999999') AND deleted = false;
 count
--------
 156377
(1 row)

db=> SELECT COUNT(DISTINCT(booking_id)) FROM booking_customer WHERE (email = '9999999999' OR phone = '9999999999') AND deleted = false;
 count
-------
 65196
(1 row)

So ideally I should have gotten 65196 Rows as a result, which may be a good reason to use sequence scan. However, the planner returns only 14 lines as an estimate. That's funny, considering that yesterday at midnight, I did vacuum analysis on both tables.

Even if I try with a different value for phone or email, giving about 1300 lines, the seq scan is still used for the booking table.

Is there a way to optimize this query?

Postgres details:

db=> SELECT version();
                                    version
-------------------------------------------------------------------------------
 PostgreSQL 9.6.12 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.9.3, 64-bit
(1 row)

Matrix – How do I solve a large system of differential equations with indexed functions?

I firmly believe that matrix methods are the right answer here, but I can not imagine how to set them up. Imagine a large number of coupled functions:

AB(m,n)(t)

Where m and n are integer indices that can be up to hundreds of thousands or thousands of thousands, and t is a continuous time variable. Imagine AB (m, n) as the concentration of AB of type (m, n), and these concentrations of different types can evolve over time. In addition, we have a single additional feature:

B(t)

it is also a concentration that evolves over time, but for which there is only one type. Initial conditions are:

AB(a,0)(0) = A0
AB(anythingelse)(0) = 0
B(0) = B0

Here a is a constant integer in the hundreds to thousands.

AB (m, n) can be converted into other types by two processes:

AB(m,n) + B --> AB(m-1,n+b)
AB(m,n) --> AB(m-1,n-1)

Here b is a constant integer that is significantly smaller than a. That is, the differential equations that determine the evolution of the system are:

D(AB(m, n)(t), t) == -k1(m, n) AB(m, n)(t) B(t) 
                     +k1(m + 1, n - b) AB(m + 1, n - b)(t) B(t) 
                     -k2(m, n) AB(m, n)(t) 
                     +k2(m + 1, n + 1) AB(m + 1, n + 1)(t)
D(B(t), t) == -k1(m, n) AB(m, n)(t) B(t)

Good assumptions for the forms for k1 and k2 that we can use for testing are:

k1(m_) = (m/a) k3
k2(m_, n_) = k4 n/(n + k5/m) + n k6 k1(m)

Here k3, k4, k5 and k6 are positive real numbers.

How on earth do I organize this system to solve it numerically? NDSolve (or ParametricNDSolve) or similar? The ultimate goal will be to have a measurable function that looks something like this:

Sum(m AB(m,n),{m,0,a},{n,0,infinity})

This function would then be suitable for experimental data that varies k3-k6 and possibly a and b. Later generalizations may be to have a broader distribution of starting concentrations, rather than all being identical, a range of different possible bs, etc.