Indexed columns in SQL Server do not appear to work for basic queries according to execution plan

Disclaimer: I’m not a DBA. I have picked up a few things from this board in the past that I’m building from.

I have a table of google analytics session start times. I have an index on each column. I want to filter for all sessions that were started between two dates. Screenshot below shows the query, and the index.

Query text and index properties

The query runs quickly but I do not believe it’s using the index based on the Execution plan which both says that there’s a missing index and shows a table scan rather than an index scan:

execution

Why?

Is it because of something about the way I’m searching through the datetime? If instead of looking between dates, I set it equal to a date, the execution plan shows it using the index:

Using index

But it’s not just this table or datetime. Here’s a different table with an index on a varchar column:

metadata index

And a simple query on this one also tells me I’m missing the index:

missing md index

I’m stumped.

exclude post according to assigned category WordPress

I have this code that shows the most viewed publications, I would like to exclude the entries assigned to a specific category, for example the ID of the category I want to exclude is "4"

  <div style="text-align:center;margin-top:4px">          <?php $  my_query = new WP_Query('meta_key=post_views_count&orderby=meta_value_num&order=DESC&showposts=6&ignore_sticky_posts=1'); while ($  my_query->have_posts()) : $  my_query->the_post(); $  do_not_duplicate = $  post->ID; ?>         <div class="recomend-posts">         <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?> (<?php $  values = get_post_custom_values("Year"); echo $  values[0]; ?>) online">             <?php if ( has_post_thumbnail() ) {?>                 <?php the_post_thumbnail('index-thumbnail');?>             <?php }else{ ?>                 <img src="<?php bloginfo('template_url');?>/images/no-image.jpg" alt="<?php the_title();?>" />             <?php }?>         </a>     </div>         <?php endwhile; wp_reset_query(); ?>         </div> 

any ideas? thanks

PostgreSQL. Consequently select results according with specific filters

I have a table with users.

User (that uses this programm) can select users by applying different filters. A filters must be applying immediatelly to reduce search time in final SELECT and no wasting time.

Currently my code looking like this (Python, not sure that this is working, not tested yet).

The question:

  1. How to applying a filters immediatelly as I get a user input?
  2. How to put/pass all actions related to filtering to DB?
if only_with_photo:     cursor.execute('SELECT tg_user_id FROM suers WHERE photo IS NOT NULL')     users_with_photo = cursor.fetchall() if only_with_country:     cursor.execute('SELECT tg_user_id FROM suers WHERE country IS NOT NULL')     users_with_country = cursor.fetchall() if only_with_city:     cursor.execute('SELECT tg_user_id FROM suers WHERE city IS NOT NULL')     users_with_city = cursor.fetchall()          cursor.execute('SELECT tg_user_id FROM users WHERE tg_user_id IN (users_with_photo) AND tg_user_id                              IN (users_with_country ) AND tg_user_id IN (users_with_city) ) 

Tasks: perform this queries inside psql without using Python or another language?

I tried:

  1. CASE sql = 'SELECT (CASE only_with_photo = 1 THEN (SELECT tg_user_id FROM users WHERE country IS NOT NULL)' --Subrequest returns more that one result
  2. Variables /set only_with_photo := (SELECT tg_user_id FROM users WHERE birthdate IS NOT NULL); --Syntax just now working

Column in query should be selected according to value from another column

Assuming I have table1 with following data:

table1

id| coffee_sender | coffee_receiver | received_bag_size | sent_bag_size| price | 21  tux              -1                  m                 -1            45  22  alsa            -1                  -1                 xl            36 23  -1               tux                 l                 -1            51 

And I use the following query:

select t1.* from ( select t.price, t.id from table1 t  where coffee_sender in (tux, alsa)  or coffee_receiver in (tux, alsa) and received_bag_size in (m, xl) or sent_bag_size in (m, xl)) t1 

What i want is to only fetch the rows that have coffee_sender/coffee_receiver AND sent_bag_size/received_bag_size filled with a value (rows that match the following conditions):

coffee_sender = tux, sent_bag_size= xl 

OR

coffee_receiver = tux, received_bag_size= m 

OR

coffee_sender = tux, sent_bag_size = xl AND coffee_receiver = tux, received_bag_size= m 

So id = 21 would be excluded from the example table1.

How can i update the above query for this ? Thank you in advance.

Use Mathematica to split a sequence according to other two sequences

I want to use Mathematica to solve the following problem:

For example I have a sequence 101. I want to compare it with $ 1101$ and $ 0101$ . The comparison has the following procedure:

  1. Check the first term of $ 101$ is $ 1$ or $ 0$ . If it is $ 1$ , compare $ 101$ to $ 1101$ , term by term; If it is $ 0$ , compare $ 101$ to $ 0101$ . Stop the process before the first term they are different, or all the terms of $ 101$ have been compared without stopping the process, and report all the terms that have been compared.

In our case, the first term of $ 101$ is $ 1$ , so we compare it with $ 1101$ . Then, $ 101$ and $ 1101$ only has one term in common, the first term $ 1$ . So the program should report $ 1$ , and go to next step.

  1. Recording the remaining sequence of $ 101$ .

In our case, as only $ 1$ is reported, the remaining sequence is $ 01$ .

  1. Restart the process. Check the first term of $ 01$ is $ 0$ or $ 1$ . If it $ 0$ , compare $ 01$ with $ 0101$ , if it is $ 1$ , compare $ 01$ with $ 1101$ . Stop the process before the first term they are different, or the sequence of $ 01$ has been run out. Report all the timers that have been compared.

*In our case, the first term of $ 01$ is $ 0$ , so we compare $ 01$ with $ 0101$ . Then the first two terms agree, and then $ 01$ ran out. The program should report $ 01$ , and then stop.

  1. Repeating the process again and again until there is no remaining sequence.

I tried to use the commend "If" to write this but it did not work, since I did not know how to let Mathematica to "remember" what has been compared.

Then, I tried to use commend "Order" and "Sort", but it seems that I need to program a comparison function.

Is there anyway for me to achieve this using Mathematica? Thank you!

What planes of existence does everyone visit while sleeping according to the Great Wheel cosmology?

When someone is sleeping what planes of existence do they visit according to the Great Wheel cosmology in D&D 5e?

I have not found exact information in the rule books about this. Perhaps there are options (good dreams on one plane, nightmares on the other)?

As far as I remember, in one of the previous editions there was a separate plane you went to while dreaming, but what about for D&D 5e?

Is there a mechanic, for example, describing a transition during sleep, a possible death during sleep, or a transition to another person’s sleep that would shed light on this issue?

Maybe there is information compatible with D&D 5th edition in the books about Planescape (since we are dealing with the Great Wheel)?

Please provide references to the sources.

The reason behind IPv6 adoption rate dramatical drop in China according to Google measurements?

Google has an IPv6 measurement page that reports that their numbers report on the percentage of users that access Google over IPv6.

According to the report by Jan 2020 0.3% of users in China used IPv6 to access Google

However, looking at this metric in dynamic we see the substantial drop starting from June 2019. enter image description here

I failed to find any solid news that may cause such behavior. I have two hypotheses in mind.

  1. Also as it is a percentage metric, they can adjust their calculation on the total internet penetration rate in China.
  2. Previously open discussions between netizens took place on Google Plus groups. In April 2019, Google shut down Google Plus. Technical discussions continue on Chinese-language blogs, forums, and groups. For obvious reasons, discussions must be hosted outside China, and posters must register under pseudonyms. So probably that caused the shift from Google services but I hardly believe that it may cause such plummet.

how to exploit user which I own according to bloodhound?

During a pentest, I succeeded to compromize a user with low privileges. As this is a domain user, I decided to run BloodHound based on its credentials to check whether there is a path from this user to domain admins.

I have the own privilege on another active directory account, which mean I should be able to change its attributes, such as userPassword, which I did, using ldp.exe. Unfortunately, Active Directory does not seem to allow authentication based on this LDAP attribute. So I needed to find something else.

I would like to use the MMC Active Directory Users and Computers but i need to be logged in as a domain member, which I can’t as I would need to integrate my PC to the domain (I prefer not to do so).

which tool can I use to act/impersonate this user I am supposed to own ?

Many thanks;

Sorting array of strings (with repetitions) according to a given ordering

We get two arrays:

ordering = ["one", "two", "three"] 

and

input = ["zero", "one", "two", "two", "three", "three", "three", "four"]; 

We want to find the array output so that

output = ["one", "two", "two", "three", "three", "three", "zero", "four"] // or output = ["one", "two", "two", "three", "three", "three", "four", "zero"] 

The strings (with possible repetitions) should be sorted as in the ordering array. Not found/contained strings should be put at the end of the new array and their order doesn’t matter.

The $ n^{2}$ solution is obvious, can we do better? The memory doesn’t matter and it doesn’t have to be an in-place algorithm.